Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ttk combobox issue

39 views
Skip to first unread message

Plebeian

unread,
Dec 24, 2007, 1:25:43 PM12/24/07
to
Hi, I am running into an issue using the ttk combobox.

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

Bryan Oakley

unread,
Dec 24, 2007, 1:36:25 PM12/24/07
to

look at the 'ttk::style map' command. There's an example here:

http://tktable.sourceforge.net/tile/doc/tile-intro.html

Plebeian

unread,
Dec 24, 2007, 2:11:57 PM12/24/07
to
Thanks for your suggestion, but i didn't get anywhere. It is most
likely 'user error'. Simply because I don't fully understand.

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

Joe English

unread,
Dec 24, 2007, 4:20:21 PM12/24/07
to
Plebeian wrote:
>
> When I use this:
>
> bind $frame1.combobox <FocusIn> "style configure TCombobox -
> fieldbackground yellow"

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

Plebeian

unread,
Dec 24, 2007, 6:45:37 PM12/24/07
to
Joe, thanks for the help.

This will take awhile to retrain myself. :)

0 new messages