For Programmers: Free Programming Magazines  


Home > Archive > Tcl > December 2007 > ttk combobox issue









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author ttk combobox issue
Plebeian

2007-12-24, 7:16 pm

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

2007-12-24, 7:16 pm

Plebeian wrote:
> 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


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

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

Plebeian

2007-12-24, 7:17 pm

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

On Dec 24, 10:36=A0am, Bryan Oakley <oak...@bardo.clearlight.com> wrote:
> Plebeian wrote:
>
>
>
>
>
> look at the 'ttk::style map' command. There's an example here:
>
> http://tktable.sourceforge.net/tile/doc/tile-intro.html


Joe English

2007-12-24, 7:17 pm

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

2007-12-24, 7:17 pm

Joe, thanks for the help.

This will take awhile to retrain myself. :)

On Dec 24, 1:20=A0pm, Joe English <jengl...@flightlab.com> wrote:
> Plebeian wrote:
>
>
>
> 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:
>
> =A0 =A0 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.
>
> =A0* * *
>
> 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. =A0Event bindings usually just change the state,
> and leaves the rest up to the theme engine and [ttk::style map].
>
> --Joe English


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com