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

ttk::treeview setting default colors (no tags)

2,316 views
Skip to first unread message

Rich

unread,
Sep 4, 2010, 5:57:42 PM9/4/10
to
What are the proper style options to specify to "ttk::style configure
Custom.Treeview" in order to change the default colors (foreground/
background) of items (the cells) in the treeview?

Thanks in advance,
Richard

Rich

unread,
Sep 5, 2010, 8:22:54 AM9/5/10
to

Through much trial, many errors, and looking through the ttk source
code
late last night, I eventually discovered the answers to my question
above:

To set the background color of the unused portion of a treeview (the
area
not covered by rows of data), use:

ttk::style configure Treeview -fieldbackground COLOR

To set the background color of rows containing data:

ttk::style configure Treeview.Row -background COLOR

To set the foreground color used for the "tree" column:

ttk::style Treeview.Item -foreground COLOR

To set the foreground of non-tree (-values) columns:

ttk::style configure Treeview.Cell -foreground COLOR

And a friend answered a question I did not yet have; to set the color
of
"selected" rows in the treeview:

ttk::style map Treeview.Row -background [ list selected COLOR ]
ttk::style map Treeview.Cell -foreground [ list selected COLOR ]
ttk::style map Treeview.Item -foreground [ list selected COLOR ]

And to change the color of the heading labels:

ttk::style map Treeview.Heading -background [ list active COLOR !
active COLOR ]

Thomas MENEZ

unread,
Sep 5, 2010, 11:17:00 AM9/5/10
to

Why not add that to the man ?

Rich

unread,
Sep 5, 2010, 11:24:47 PM9/5/10
to

Patch file against the man page uploaded to Sourceforge.

Also, see http://wiki.tcl.tk/26993.

Schelte Bron

unread,
Sep 6, 2010, 3:18:51 PM9/6/10
to
Rich wrote:
> To set the background color of rows containing data:
>
> ttk::style configure Treeview.Row -background COLOR
>
> To set the foreground color used for the "tree" column:
>
> ttk::style Treeview.Item -foreground COLOR
>
> To set the foreground of non-tree (-values) columns:
>
> ttk::style configure Treeview.Cell -foreground COLOR
>
Seems like you figured this out for Tk 8.5.8 or earlier. In (the
soon to be released) Tk 8.5.9 the above commands have no effect.
Instead you can simply use:
ttk::style configure Treeview -background COLOR
And:
ttk::style configure Treeview -foreground COLOR

If you want to support both 8.5.8 and 8.5.9 you can just do both.


Schelte.

0 new messages