• Question about textvariable differences between button and ttk::button

    From Donald Rozenberg@21:1/5 to All on Sun Jan 16 08:26:38 2022
    I have noticed that when the textvariable option is specified for a button widget the variable its value is set to the current value of the button text
    while specifying the textvariable option for a ttk::button widget leaves the variable unset. This is demonstrated in the following snippet.

    button .b -text Button
    ttk::button .tb -text Tbutton
    pack .b .tb
    .b configure -textvariable vb
    .tb configure -textvariable vt
    puts "vb = $vb"
    puts [info exists vt]

    This textvariable implementation extends to other ttk widgets besides ttk::button widgets.

    I consider this to be a significant design oversite - bug - and hope it will be corrected. I have an Open Source tkinter GUI generator called PAGE written in tcl and this is causing me fits.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alexandru@21:1/5 to Donald Rozenberg on Sun Jan 16 10:44:24 2022
    Donald Rozenberg schrieb am Sonntag, 16. Januar 2022 um 17:26:40 UTC+1:
    I have noticed that when the textvariable option is specified for a button widget the variable its value is set to the current value of the button text
    while specifying the textvariable option for a ttk::button widget leaves the variable unset. This is demonstrated in the following snippet.

    button .b -text Button
    ttk::button .tb -text Tbutton
    pack .b .tb
    .b configure -textvariable vb
    .tb configure -textvariable vt
    puts "vb = $vb"
    puts [info exists vt]

    This textvariable implementation extends to other ttk widgets besides ttk::button widgets.

    I consider this to be a significant design oversite - bug - and hope it will be corrected. I have an Open Source tkinter GUI generator called PAGE written in tcl and this is causing me fits.

    I don't understand what you mean. Your code works for me as expected. I can set the ::vt variable and the ttk button updates automatically.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mike Griffiths@21:1/5 to Alexandru on Sun Jan 16 15:19:51 2022
    On Sunday, 16 January 2022 at 18:44:26 UTC, Alexandru wrote:
    Donald Rozenberg schrieb am Sonntag, 16. Januar 2022 um 17:26:40 UTC+1:
    I have noticed that when the textvariable option is specified for a button widget the variable its value is set to the current value of the button text
    while specifying the textvariable option for a ttk::button widget leaves the variable unset. This is demonstrated in the following snippet.

    button .b -text Button
    ttk::button .tb -text Tbutton
    pack .b .tb
    .b configure -textvariable vb
    .tb configure -textvariable vt
    puts "vb = $vb"
    puts [info exists vt]

    This textvariable implementation extends to other ttk widgets besides ttk::button widgets.

    I consider this to be a significant design oversite - bug - and hope it will be corrected. I have an Open Source tkinter GUI generator called PAGE written in tcl and this is causing me fits.
    I don't understand what you mean. Your code works for me as expected. I can set the ::vt variable and the ttk button updates automatically.
    When the variables aren't set before you configure -textvariable, configuring -textvariable on a [button] preserves the current -text option by creating and setting the variable to that value. [ttk::button] does not, so it wipes the current value (from -
    text) and overrides it with a blank value from the non-existant -textvariable variable. If you run the example above, you'll see the button still says "Button" but the ttk::button loses its label and becomes blank.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Donald Rozenberg@21:1/5 to Mike Griffiths on Sun Jan 16 16:25:03 2022
    On Sunday, January 16, 2022 at 3:19:53 PM UTC-8, Mike Griffiths wrote:
    On Sunday, 16 January 2022 at 18:44:26 UTC, Alexandru wrote:
    Donald Rozenberg schrieb am Sonntag, 16. Januar 2022 um 17:26:40 UTC+1:
    I have noticed that when the textvariable option is specified for a button widget the variable its value is set to the current value of the button text
    while specifying the textvariable option for a ttk::button widget leaves the variable unset. This is demonstrated in the following snippet.

    button .b -text Button
    ttk::button .tb -text Tbutton
    pack .b .tb
    .b configure -textvariable vb
    .tb configure -textvariable vt
    puts "vb = $vb"
    puts [info exists vt]

    This textvariable implementation extends to other ttk widgets besides ttk::button widgets.

    I consider this to be a significant design oversite - bug - and hope it will be corrected. I have an Open Source tkinter GUI generator called PAGE written in tcl and this is causing me fits.
    I don't understand what you mean. Your code works for me as expected. I can set the ::vt variable and the ttk button updates automatically.
    When the variables aren't set before you configure -textvariable, configuring -textvariable on a [button] preserves the current -text option by creating and setting the variable to that value. [ttk::button] does not, so it wipes the current value (from
    -text) and overrides it with a blank value from the non-existant -textvariable variable. If you run the example above, you'll see the button still says "Button" but the ttk::button loses its label and becomes blank.

    I understand what is happening. My complaint is that the behavors are different and I think that they should be the same and I prefer the button behavor over the ttk::button.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harald Oehlmann@21:1/5 to All on Mon Jan 17 08:35:10 2022
    Am 17.01.2022 um 01:25 schrieb Donald Rozenberg:
    On Sunday, January 16, 2022 at 3:19:53 PM UTC-8, Mike Griffiths wrote:
    On Sunday, 16 January 2022 at 18:44:26 UTC, Alexandru wrote:
    Donald Rozenberg schrieb am Sonntag, 16. Januar 2022 um 17:26:40 UTC+1: >>>> I have noticed that when the textvariable option is specified for a button widget the variable its value is set to the current value of the button text
    while specifying the textvariable option for a ttk::button widget leaves the variable unset. This is demonstrated in the following snippet.

    button .b -text Button
    ttk::button .tb -text Tbutton
    pack .b .tb
    .b configure -textvariable vb
    .tb configure -textvariable vt
    puts "vb = $vb"
    puts [info exists vt]

    This textvariable implementation extends to other ttk widgets besides ttk::button widgets.

    I consider this to be a significant design oversite - bug - and hope it will be corrected. I have an Open Source tkinter GUI generator called PAGE written in tcl and this is causing me fits.
    I don't understand what you mean. Your code works for me as expected. I can set the ::vt variable and the ttk button updates automatically.
    When the variables aren't set before you configure -textvariable, configuring -textvariable on a [button] preserves the current -text option by creating and setting the variable to that value. [ttk::button] does not, so it wipes the current value (
    from -text) and overrides it with a blank value from the non-existant -textvariable variable. If you run the example above, you'll see the button still says "Button" but the ttk::button loses its label and becomes blank.

    I understand what is happening. My complaint is that the behavors are different and I think that they should be the same and I prefer the button behavor over the ttk::button.

    Donald,
    thank you for the valuable observation and proposition. Please file a
    bug report at the tk bug tracker (core.tcl-lang.org/tk)

    Thank you and take care,
    Harald

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mike Griffiths@21:1/5 to Donald Rozenberg on Mon Jan 17 15:26:43 2022
    On Monday, 17 January 2022 at 00:25:06 UTC, Donald Rozenberg wrote:
    On Sunday, January 16, 2022 at 3:19:53 PM UTC-8, Mike Griffiths wrote:
    On Sunday, 16 January 2022 at 18:44:26 UTC, Alexandru wrote:
    Donald Rozenberg schrieb am Sonntag, 16. Januar 2022 um 17:26:40 UTC+1:
    I have noticed that when the textvariable option is specified for a button widget the variable its value is set to the current value of the button text
    while specifying the textvariable option for a ttk::button widget leaves the variable unset. This is demonstrated in the following snippet.

    button .b -text Button
    ttk::button .tb -text Tbutton
    pack .b .tb
    .b configure -textvariable vb
    .tb configure -textvariable vt
    puts "vb = $vb"
    puts [info exists vt]

    This textvariable implementation extends to other ttk widgets besides ttk::button widgets.

    I consider this to be a significant design oversite - bug - and hope it will be corrected. I have an Open Source tkinter GUI generator called PAGE written in tcl and this is causing me fits.
    I don't understand what you mean. Your code works for me as expected. I can set the ::vt variable and the ttk button updates automatically.
    When the variables aren't set before you configure -textvariable, configuring -textvariable on a [button] preserves the current -text option by creating and setting the variable to that value. [ttk::button] does not, so it wipes the current value (
    from -text) and overrides it with a blank value from the non-existant -textvariable variable. If you run the example above, you'll see the button still says "Button" but the ttk::button loses its label and becomes blank.
    I understand what is happening. My complaint is that the behavors are different and I think that they should be the same and I prefer the button behavor over the ttk::button.
    I was replying to Alexandru who said he did not :)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Emiliano@21:1/5 to All on Tue Jan 18 07:31:27 2022
    El domingo, 16 de enero de 2022 a las 13:26:40 UTC-3, Donald Rozenberg escribió:
    I have noticed that when the textvariable option is specified for a button widget the variable its value is set to the current value of the button text
    while specifying the textvariable option for a ttk::button widget leaves the variable unset. This is demonstrated in the following snippet.

    button .b -text Button
    ttk::button .tb -text Tbutton
    pack .b .tb
    .b configure -textvariable vb
    .tb configure -textvariable vt
    puts "vb = $vb"
    puts [info exists vt]

    This textvariable implementation extends to other ttk widgets besides ttk::button widgets.

    I consider this to be a significant design oversite - bug - and hope it will be corrected. I have an Open Source tkinter GUI generator called PAGE written in tcl and this is causing me fits.

    This is a design decision.
    All ttk widgets share the same implementation of the -*variable option behaviour (see generic/ttk/ttkTrace.c source file).
    Note that ttk::checkbutton depends on this behaviour to implement its tristate feature.
    Back in the day Joe English, main designer and implementator of tile/ttk, used to explain in the tcler's chat why this was a better design than Tk's. Sadly there's no record of such explanations.

    Regards
    Emiliano

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alexandru@21:1/5 to Mike Griffiths on Thu Jan 20 15:57:42 2022
    Mike Griffiths schrieb am Dienstag, 18. Januar 2022 um 00:26:46 UTC+1:
    On Monday, 17 January 2022 at 00:25:06 UTC, Donald Rozenberg wrote:
    On Sunday, January 16, 2022 at 3:19:53 PM UTC-8, Mike Griffiths wrote:
    On Sunday, 16 January 2022 at 18:44:26 UTC, Alexandru wrote:
    Donald Rozenberg schrieb am Sonntag, 16. Januar 2022 um 17:26:40 UTC+1:
    I have noticed that when the textvariable option is specified for a button widget the variable its value is set to the current value of the button text
    while specifying the textvariable option for a ttk::button widget leaves the variable unset. This is demonstrated in the following snippet.

    button .b -text Button
    ttk::button .tb -text Tbutton
    pack .b .tb
    .b configure -textvariable vb
    .tb configure -textvariable vt
    puts "vb = $vb"
    puts [info exists vt]

    This textvariable implementation extends to other ttk widgets besides ttk::button widgets.

    I consider this to be a significant design oversite - bug - and hope it will be corrected. I have an Open Source tkinter GUI generator called PAGE written in tcl and this is causing me fits.
    I don't understand what you mean. Your code works for me as expected. I can set the ::vt variable and the ttk button updates automatically.
    When the variables aren't set before you configure -textvariable, configuring -textvariable on a [button] preserves the current -text option by creating and setting the variable to that value. [ttk::button] does not, so it wipes the current value (
    from -text) and overrides it with a blank value from the non-existant -textvariable variable. If you run the example above, you'll see the button still says "Button" but the ttk::button loses its label and becomes blank.
    I understand what is happening. My complaint is that the behavors are different and I think that they should be the same and I prefer the button behavor over the ttk::button.
    I was replying to Alexandru who said he did not :)

    I have misunderstood the original issue. Indeed I can confirm the behavior. But I like the new behavior. I wouldn't change it.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jtyler@21:1/5 to Alexandru on Thu Jan 20 19:51:44 2022
    On 1/20/2022 3:57 PM, Alexandru wrote:
    Mike Griffiths schrieb am Dienstag, 18. Januar 2022 um 00:26:46 UTC+1:
    On Monday, 17 January 2022 at 00:25:06 UTC, Donald Rozenberg wrote:
    On Sunday, January 16, 2022 at 3:19:53 PM UTC-8, Mike Griffiths wrote:
    On Sunday, 16 January 2022 at 18:44:26 UTC, Alexandru wrote:
    Donald Rozenberg schrieb am Sonntag, 16. Januar 2022 um 17:26:40 UTC+1: >>>>>> I have noticed that when the textvariable option is specified for a button widget the variable its value is set to the current value of the button text
    while specifying the textvariable option for a ttk::button widget leaves the variable unset. This is demonstrated in the following snippet.

    button .b -text Button
    ttk::button .tb -text Tbutton
    pack .b .tb
    .b configure -textvariable vb
    .tb configure -textvariable vt
    puts "vb = $vb"
    puts [info exists vt]

    This textvariable implementation extends to other ttk widgets besides ttk::button widgets.

    I consider this to be a significant design oversite - bug - and hope it will be corrected. I have an Open Source tkinter GUI generator called PAGE written in tcl and this is causing me fits.
    I don't understand what you mean. Your code works for me as expected. I can set the ::vt variable and the ttk button updates automatically.
    When the variables aren't set before you configure -textvariable, configuring -textvariable on a [button] preserves the current -text option by creating and setting the variable to that value. [ttk::button] does not, so it wipes the current value (
    from -text) and overrides it with a blank value from the non-existant -textvariable variable. If you run the example above, you'll see the button still says "Button" but the ttk::button loses its label and becomes blank.
    I understand what is happening. My complaint is that the behavors are different and I think that they should be the same and I prefer the button behavor over the ttk::button.
    I was replying to Alexandru who said he did not :)

    I have misunderstood the original issue. Indeed I can confirm the behavior. But I like the new behavior. I wouldn't change it.


    There's another difference. With ttk, once you set the variable vt and
    the ttk::button changes its label, if you then unset vt, the variable is
    unset AND the ttk::button label is set back to empty.

    With the tk button, if you unset the variable, nothing happens to the
    label, AND the variable remains set. Perhaps it is unset and then an
    event occurs to re-set it back to the value, that I don't know, but the
    effect is to ignore the unset.

    I'm with the OP and would like it better if both buttons shared the same behaviors. I don't much care which one became the standard, just that
    they were the same.

    There's a TIP that asked for more compatibility between ttk and tk and
    I'm for that. I often switch between the two, but that rarely works. I
    once wrote some code to detect using -bg and -fg on ttk::button and to
    invoke the ttk code to make the same change, but never really used it.

    Those are probably the two most annoying things in ttk for me. The other
    is the lack of detailed information (with examples) on how to change
    things with ttk. I consider ttk an art. I've had to look at code such as
    the dark theme to see examples.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)