My app changes the background color of the entry widgets when it is in
focus, but how can i do this with the combobox? (They are TK entry
widgets, currently)
I have tried the documentation on Tile, but it was rather sparse when
it came to [style configure].
I can change the background when the app starts up, but i'd only like
to do it on <FocusIn> and <FocusOut>
Thanks
look at the 'ttk::style map' command. There's an example here:
When I use this:
bind $frame1.combobox <FocusIn> "style configure TCombobox -
fieldbackground yellow"
It works just fine. However, I have two comboboxes, and this code
activates the yellow for both of them. Is there anyway to single them
out seperatly?
Thanks
That says: "When $frame1.combobox receives the focus,
set the default -fieldbackground for all comboboxes."
That's not what you want.
Instead, what you want is "The -fieldbackground for a
combobox should be yellow whenever it has the focus."
Here's how you say that:
ttk::style map TCombobox -fieldbackground [list focus yellow]
You'll probably want to add settings for the 'readonly'
and 'disabled' states, too.
You don't need to add any <FocusIn> or <FocusOut> bindings,
the widget tracks those and sets the 'focus' state flag
automatically.
* * *
This is an example of what's probably the biggest difference
between the core widgets and Tile: instead of directly changing
options when an event is received, or having multiple options for
state-specific variants (like -disabledforeground, -activebackground,
etc., ...), in Tile most options are -- or at least can be -- a function
of the widget state. Event bindings usually just change the state,
and leaves the rest up to the theme engine and [ttk::style map].
--Joe English
This will take awhile to retrain myself. :)