Tk Source Code

View Ticket
Login
Ticket UUID: d632d28ba4368a4ee02c69ac28f4c039661c500
Title: Themes specifying images for open/close indicators for treeview items no more working in tk 9
Type: Bug Version: 9.0.1
Submitter: anonymous Created on: 2025-02-03 13:09:03
Subsystem: 88. Themed Tk Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2025-05-03 16:10:25
Resolution: None Closed By: nobody
    Closed on:
Description:

In tcl/tk 8.6, it was possible to specify a style for a treeview with images for the open/close indicator for items by doing something like:

ttk::style element create Treeitem.indicator \
              image [list $image_for_closed \
                  user1 $image_for_open \
                  user2 $image_for_no_children \
              ] ...

This doesn't seem to work anymore with tk 9.0.1: with the code above, the image for the open/close indicator is always the one specified as the default - i.e $image_for_closed in the code above -, even if the item has no children, or if it has children and is opened.

User Comments: oehhar added on 2025-05-03 16:10:25:
Please find now TIP 719 proposal:

[https://core.tcl-lang.org/tips/doc/trunk/tip/719.md]

I think, this is a good idea !

Harald

EricBrunel added on 2025-02-04 15:36:55:

Having names at script level for the 'open', 'leaf', 'first' and 'last' states is a neat solution, yes. This will require some changes in the themes, but it's for the better: the 'user1' and 'user2' states were weird anyway.


jan.nijtmans added on 2025-02-04 11:47:32:

How about [7d1b122e9c002e89|this]?

In 8.6, there was a limitation of 16 flags (because it was stored in a 32-bit integer, 2 bits for each flag). In 9.0, this is extended to 32 flags, so there is no problem defining 4 additional values.

A TIP should be written for this, but see no reason to reject that.


EricBrunel added on 2025-02-04 09:27:46:

OP here. I dived a bit in the source code for tk, and indeed, the 'open' and 'leaf' states that were mapped to 'user1' and 'user2' in tk 8.6 are now internal states, defined in generic/ttk/ttkThemeInt.h. I actually tried to comment out their definitions and to restore the previous mapping by doing:

#define TTK_STATE_OPEN		TTK_STATE_USER1
#define TTK_STATE_LEAF		TTK_STATE_USER2

and it seems to work: the image-based themes defined for tk 8.6 now work as they used to with this modification.

So I can live with this workaround for now, as long as it doesn't have any nasty side-effects. But I'm wondering why the internal states are internal at all: why not name them with a more explicit name than 'userX' and make them usable in themes?

Anyway, this should be documented somewhere, as this breaks some themes that were working fine before.


fvogel added on 2025-02-03 19:50:40:

I think [527cb3cd5d] could shed light on this.