Similar issues were confronted long ago in the ttk source code.
For background, see