Tk Source Code

View Ticket
Login
2023-09-01
20:35 Ticket [6c40d702] ttk::treeview don't honor -fieldbackground status still Open with 3 other changes artifact: c67c6491 user: chrstphrchvz
2021-11-28
23:22 Ticket [f3a91eb6] TEntry fieldbackground does not work with vista theme on windows status still Open with 3 other changes artifact: 7bb74a70 user: chrstphrchvz
2020-11-15
13:58 Ticket [b46642fe] Custom treeview -fieldbackground and header -background unused for vista/xpnative Ttk themes status still Closed with 4 other changes artifact: 8f88ba48 user: fvogel
2020-10-31
13:11 Closed ticket [b46642fe]. artifact: 4b6668ea user: fvogel
2020-08-17
06:55 Ticket [b46642fe]: 3 changes artifact: 30ae1cb3 user: fvogel
06:55 Ticket [3eb2a8df] Custom treeview header -background unused for aqua Ttk theme status still Open with 3 other changes artifact: 380b9a0d user: fvogel
2020-08-16
12:10 Ticket [b46642fe] Custom treeview -fieldbackground and header -background unused for vista/xpnative Ttk themes status still Open with 4 other changes artifact: d96406b4 user: fvogel
2020-07-25
20:21 Ticket [b46642fe]: 3 changes artifact: bc1ff889 user: chrstphrchvz
10:26 Ticket [b46642fe]: 3 changes artifact: ce4c67b2 user: fvogel
2020-07-23
20:57 New ticket [b46642fe]. artifact: edf38dd1 user: chrstphrchvz

Ticket UUID: b46642fe3b86037dc82a9765ce54f80312c9d90e
Title: Custom treeview -fieldbackground and header -background unused for vista/xpnative Ttk themes
Type: Bug Version: 8.6.10
Submitter: chrstphrchvz Created on: 2020-07-23 20:57:32
Subsystem: 88. Themed Tk Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2020-11-15 13:58:29
Resolution: Wont Fix Closed By: fvogel
    Closed on: 2020-11-15 13:58:29
Description:

The vista and xpnative Ttk themes do not use the -fieldbackground setting for treeview widgets, configurable using:

ttk::style configure Treeview -fieldbackground $color

Nor do these themes use the -background for treeview headers, as configured using:

ttk::style configure Heading -background $color

Other Ttk themes such as default will use these colors.

Left screenshot: vista theme; right screenshot: default theme (showing custom -fieldbackground and header -background colors).

User Comments: fvogel added on 2020-11-15 13:58:29:

TIP #584 is now merged in main, and could help since it provides new introspection capabilities in ttk.


fvogel added on 2020-10-31 13:11:11:

A very clear and thorough reference on the topic is the (recently updated) tkdocs.

I'm closing this tikcet now.


fvogel added on 2020-08-17 06:55:34:

X-ref: [3eb2a8df64], similar discussion.


fvogel added on 2020-08-16 12:10:50:

With Tk 8.6.10 on Windows 10 2004, I observe the treeview -fieldbackground and heading -background being used by the winnative, clam, default, alt, and classic themes. I'm not sure why you only observe this only for the clam theme, but I would note that doing ttk::style configure -option value only affects the current theme; if a new theme is loaded using ttk::style theme use newtheme, then the customizations for the previous theme are unloaded.

That's not really correct. On Windows, try:

ttk::style theme use clam
ttk::style configure Treeview -fieldbackground green
ttk::style configure Heading -background red
# red and green now shown
ttk::style theme use xpnative
# red and green no longer shown
ttk::style theme use clam
# red and green shown again, without a need to configure again

That observed, I'm unsure why I said only clam uses these style configuration options, because obviously I was wrong and your observations are correct. On Windows, only the xpnative and vista themes ignore these style options.

I'm very tempted to close this ticket as WON'T FIX, for the reasons I already stated. The fact that some options are not available for all themes is documented, and I really think that is intentional: once the look of the widget is obtained through a given set of options for a given theme, there is no point in adding further options in that theme because the whole point of ttk is to get that platform-native widget look, thus goal is reached. The use case of people wanting a readily available treeview from the core Tk could be a use case of customization, however I believe it's just not compatible with the ttk goals. Such users should rather integrate Tablelist, or TreeCtrl, or whatever other suitable treeview for that customisation purpose IMO. Finally, and this is probably the final argument, the xpnative and vista themes are implemented through the "Visual Styles" API, which simply does not provide such configuration choices. For instance the treeview field area is a TVP_TREEITEM part, and there is no way to my knowledge to change its color.


chrstphrchvz added on 2020-07-25 20:21:41:

Francois, thanks for pointing out the limitation described in the (relatively new) documentation. However it doesn't elaborate whether this limitation is intentional (e.g. for consistency with platform appearance) or unintentional (bugs/regressions, or behavior that never got implemented).

I was helping a user figure out how these options could be changed from a Tcl/Tk wrapper for Perl, and noticed inconsistencies between themes. I do not know what their exact goal for customizing the treeview. But I think someone may want to use ttk::treeview simply because it is a readily-available table-like widget in core Tk, and not necessarily for native theming purposes.

With Tk 8.6.10 on Windows 10 2004, I observe the treeview -fieldbackground and heading -background being used by the winnative, clam, default, alt, and classic themes. I'm not sure why you only observe this only for the clam theme, but I would note that doing ttk::style configure -option value only affects the current theme; if a new theme is loaded using ttk::style theme use newtheme, then the customizations for the previous theme are unloaded.


fvogel added on 2020-07-25 10:26:48:

On which platform do you see this?

For me on Windows (Vista):

% ttk::style theme names
winnative clam alt default classic vista xpnative

Among those only clam shows the fieldbackground and heading background colors that were configured through the ttk::style command. In particular, default apparently does not.

Anyway, I must be missing something: what's the point in customizing treeviews within, say, the vista theme? Themes are here to show native look to the user as much as possible and I can't see why a user would like to set a green fieldbackground or red heading background whereas at the same time he requested a vista (i.e. platform native looking) theme.

Also, the man page for ttk::treeview warns about this in the "STYLING OPTIONS" section: "Some options are only available for specific themes."