• Treeview item indicators in image-based themes vs Tk 9

    From Eric Brunel@eric.brunel@pragmadev.com to comp.lang.tcl on Mon Feb 3 10:22:31 2025
    From Newsgroup: comp.lang.tcl

    Hello all,

    I've recently switched to tcl/tk 9.0 and I discovered what seems to be an issue with image-based themes having an image for the treeview item open/
    close indicators.

    In tcl/tk 8.6, the styling for these indicators are usually done via
    something like this:

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

    But this doesn't seem to work in tk 9: now all items have an indicator
    showing the image_for_closed whether they have children or not, and
    whether the item is opened or not.

    I suspect a change in the names for the states "user1" and "user2" - which were admittedly not very user-friendly - but I just can't find any
    reference for these, and by what I should replace them in tk 9 if that's indeed the problem.

    Any pointers would be greatly appreciated.

    Thanks!
    --
    Eric
    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From Harald Oehlmann@wortkarg3@yahoo.com to comp.lang.tcl on Mon Feb 3 11:40:23 2025
    From Newsgroup: comp.lang.tcl

    Am 03.02.2025 um 11:22 schrieb Eric Brunel:
    Hello all,

    I've recently switched to tcl/tk 9.0 and I discovered what seems to be an issue with image-based themes having an image for the treeview item open/ close indicators.

    In tcl/tk 8.6, the styling for these indicators are usually done via something like this:

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

    But this doesn't seem to work in tk 9: now all items have an indicator showing the image_for_closed whether they have children or not, and
    whether the item is opened or not.

    I suspect a change in the names for the states "user1" and "user2" - which were admittedly not very user-friendly - but I just can't find any
    reference for these, and by what I should replace them in tk 9 if that's indeed the problem.

    Any pointers would be greatly appreciated.

    Thanks!
    --
    Eric

    Thanks, Eric,
    I lightly remeber some discussion on this by Csaba, when those images
    passed to svg format with Tk 9.
    It would be worthwile to post this as tk bug, as the migration notes
    dont mention this: https://core.tcl-lang.org/tk/wiki?name=Migrating+scripts+to+Tk+9&p

    Thanks,
    Harald
    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From Eric Brunel@eric.brunel@pragmadev.com to comp.lang.tcl on Mon Feb 3 17:00:16 2025
    From Newsgroup: comp.lang.tcl

    On Mon, 3 Feb 2025 11:40:23 +0100, Harald Oehlmann wrote:

    Am 03.02.2025 um 11:22 schrieb Eric Brunel:
    Hello all,

    I've recently switched to tcl/tk 9.0 and I discovered what seems to be
    an issue with image-based themes having an image for the treeview item
    open/ close indicators.

    In tcl/tk 8.6, the styling for these indicators are usually done via
    something like this:

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

    But this doesn't seem to work in tk 9: now all items have an indicator
    showing the image_for_closed whether they have children or not, and
    whether the item is opened or not.

    I suspect a change in the names for the states "user1" and "user2" -
    which were admittedly not very user-friendly - but I just can't find
    any reference for these, and by what I should replace them in tk 9 if
    that's indeed the problem.

    Any pointers would be greatly appreciated.

    Thanks!
    -- Eric

    Thanks, Eric,
    I lightly remeber some discussion on this by Csaba, when those images
    passed to svg format with Tk 9.
    It would be worthwile to post this as tk bug, as the migration notes
    dont mention this: https://core.tcl-lang.org/tk/wiki?name=Migrating+scripts+to+Tk+9&p


    Thanks,
    Harald


    Thanks Harald. I did post this as a tk bug.

    I've also dived a little into the source code, and I think I found out the culprit: in generic/ttk/ttkThemeInt.h, there is a set of #define
    directives that go:

    #define TTK_STATE_OPEN (1<<16)
    #define TTK_STATE_LEAF (1<<17)
    #define TTK_STATE_FIRST (1<<18)
    #define TTK_STATE_LAST (1<<19)

    while in generic/ttk/ttkTheme.h, the constants for the states that are accessible for styling only go up to (1<<15) for TTK_STATE_USER1. So it
    seems the states the represent the 'open' and 'leaf' states for treeview
    items can no more be used in styles, which is a bit of a shame.

    But if I replace the first two defines in ttkThemeInt.h with:

    #define TTK_STATE_OPEN TTK_STATE_USER1
    #define TTK_STATE_LEAF TTK_STATE_USER2

    I can get the old behavior back, and the image-based styles work as they
    used to. So I'm going to keep it that way for now. I hope it won't cause
    any weird side effect.

    Thanks again!
    --
    Eric
    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From Francois Vogel@francois.vogel.fv.NOSPAM@gmail.com to comp.lang.tcl on Mon Feb 3 20:50:23 2025
    From Newsgroup: comp.lang.tcl

    Le 03/02/2025 à 11:22, Eric Brunel a écrit :
    In tcl/tk 8.6, the styling for these indicators are usually done via something like this:

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

    But this doesn't seem to work in tk 9: now all items have an indicator showing the image_for_closed whether they have children or not, and
    whether the item is opened or not.

    I suspect a change in the names for the states "user1" and "user2" - which were admittedly not very user-friendly - but I just can't find any
    reference for these, and by what I should replace them in tk 9 if that's indeed the problem.

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

    https://core.tcl-lang.org/tk/info/527cb3cd5d

    Regards,
    Francois

    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From Eric Brunel@eric.brunel@pragmadev.com to comp.lang.tcl on Tue Feb 4 09:38:49 2025
    From Newsgroup: comp.lang.tcl

    On Mon, 3 Feb 2025 20:50:23 +0100, Francois Vogel wrote:

    Le 03/02/2025 à 11:22, Eric Brunel a écrit :
    In tcl/tk 8.6, the styling for these indicators are usually done via
    something like this:

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

    But this doesn't seem to work in tk 9: now all items have an indicator
    showing the image_for_closed whether they have children or not, and
    whether the item is opened or not.

    I suspect a change in the names for the states "user1" and "user2" -
    which were admittedly not very user-friendly - but I just can't find
    any reference for these, and by what I should replace them in tk 9 if
    that's indeed the problem.

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

    https://core.tcl-lang.org/tk/info/527cb3cd5d

    Regards,
    Francois

    Thanks for that. I've seen the argument about not using internally states
    that are supposed to be user-defined, and I can understand that,
    especially considering this never seemed to be correctly documented.

    Now no more being able to do in themes what was possible in tk 8.6 is a
    bit of a shame. Which brings the question: why have internal states at
    all? The states 'open', 'leaf', 'first' and 'last' are indeed very
    specific to some elements, but as long as they can be used in themes, it
    might be nice to actually have them named and usable...

    Thanks again!
    Eric
    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From Harald Oehlmann@wortkarg3@yahoo.com to comp.lang.tcl on Tue Feb 4 10:48:23 2025
    From Newsgroup: comp.lang.tcl

    Am 04.02.2025 um 10:38 schrieb Eric Brunel:
    On Mon, 3 Feb 2025 20:50:23 +0100, Francois Vogel wrote:

    Le 03/02/2025 à 11:22, Eric Brunel a écrit :
    In tcl/tk 8.6, the styling for these indicators are usually done via
    something like this:

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

    But this doesn't seem to work in tk 9: now all items have an indicator
    showing the image_for_closed whether they have children or not, and
    whether the item is opened or not.

    I suspect a change in the names for the states "user1" and "user2" -
    which were admittedly not very user-friendly - but I just can't find
    any reference for these, and by what I should replace them in tk 9 if
    that's indeed the problem.

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

    https://core.tcl-lang.org/tk/info/527cb3cd5d

    Regards,
    Francois

    Thanks for that. I've seen the argument about not using internally states that are supposed to be user-defined, and I can understand that,
    especially considering this never seemed to be correctly documented.

    Now no more being able to do in themes what was possible in tk 8.6 is a
    bit of a shame. Which brings the question: why have internal states at
    all? The states 'open', 'leaf', 'first' and 'last' are indeed very
    specific to some elements, but as long as they can be used in themes, it might be nice to actually have them named and usable...

    Thanks again!
    Eric

    Eric,
    I think, this should be solved.
    Please discuss in the ticket.

    We have a public Tk telco today 16:00 UTC on the TCL Jitsi.
    Maybe, we may speak about this.


    Take care,
    Harald

    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From Paul Obermeier@obermeier@poSoft.de to comp.lang.tcl on Tue Feb 4 15:01:26 2025
    From Newsgroup: comp.lang.tcl

    Am 04.02.2025 um 10:48 schrieb Harald Oehlmann:


    Eric,
    I think, this should be solved.
    Please discuss in the ticket.

    We have a public Tk telco today 16:00 UTC on the TCL Jitsi.
    Maybe, we may speak about this.


    The time should be 18:00 UTC !
    --- Synchronet 3.20c-Linux NewsLink 1.2