Re: Python3.6 tkinter bug?

2022-09-22 Thread Peter Smith
On Wednesday, February 1, 2017 at 11:55:35 AM UTC, Terry Reedy wrote:
> On 2/1/2017 1:37 AM, Christian Gollwitzer wrote: 
> > Am 01.02.17 um 00:02 schrieb MRAB: 
> >> On 2017-01-31 22:34, Christian Gollwitzer wrote: 
>  .!frame.!checkbutton 
>  .!frame.!checkbutton2 
>  .!frame2.!checkbutton 
>  .!frame2.!checkbutton2 
> >>> 
> >>> 
> >> Perhaps someone who knows Tcl and tk can tell me, but I notice that in 
> >> the first example, the second part of the widget names are unique, 
> >> whereas in the second example, the second part of the widget names are 
> >> the reused (both "!checkbutton" and "!checkbutton2" occur twice). 
> > 
> > It is indeed the reason, but it has some strange legacy cause: the 
> > default name for the checkbutton-linked variable is the name of the 
> > button inside the parent. Therefore creating a checkbutton has the side 
> > effect of creating a variable with the button's name. 
> > 
> > In this case, the first buttons in the frames are linked to a variable 
> > called "!checkbutton" and the other two are linked to "!checkbutton2". 
> > (a variable name in Tcl can be anything apart from the empty string). 
> > This can also be demonstrated by this Tcl script: 
> > 
> > package require Tk 
> > 
> > pack [frame .f1] 
> > pack [frame .f2] 
> > 
> > pack [checkbutton .f1.c1 -text "A" ] 
> > pack [checkbutton .f1.c2 -text "B" ] 
> > 
> > pack [checkbutton .f2.c1 -text "C" ] 
> > pack [checkbutton .f2.c2 -text "D" ] 
> > 
> > which is equivalent to the Python code above. 
> > 
> > Note that this surprising behaviour was corrected for the (modern) ttk 
> > widgets, so if "checkbutton" is replaced by "ttk::checkbutton", they are 
> > not any longer linked. In Python, that would be 
> > 
> > from tkinter import ttk 
> > ... 
> > w = ttk.Checkbutton() 
> > 
> > (Personally, I'm not using the legacy widgets any longer)
> Christian, could you repeat any relevant parts of your comments on the 
> tracker, especially any ideas on how we might fix tkinter? 
> https://bugs.python.org/issue29402
> >> Do the names need to be: 
> >> 
> >> .!frame.!checkbutton 
> >> .!frame.!checkbutton2 
> >> .!frame2.!checkbutton3 
> >> .!frame2.!checkbutton4
> Serhiy considered that but, not knowing that this would cause a 
> regression, we both liked numbering within parent better. 
> 
> There is a similar issue with radiobuttons on ttk.OptionMenus that 
> existed *before* the 3.6 name changes. 
> https://bugs.python.org/issue25684 
> So there seems to be a systematic issue with tk or how we are (mis)using it.
> > Good question. Maybe there should be unique variable names? I.e., if the 
> > script is changed into package require Tk 
> > 
> > pack [frame .f1] 
> > pack [frame .f2] 
> > 
> > pack [checkbutton .f1.c1 -text "A" -variable v1] 
> > pack [checkbutton .f1.c2 -text "B" -variable v2] 
> > 
> > pack [checkbutton .f2.c1 -text "C" -variable v3] 
> > pack [checkbutton .f2.c2 -text "D" -variable v4] 
> > 
> > then they are also not linked.
> -- 
> Terry Jan Reedy

It looks as if the issue is indeed that the expression to the right of 
CheckButton(... variable= must be an expression.

This works for me
   global checkbix, checkbuttons
   checkbix += 1
   b = tk.Checkbutton(frame, text=text, variable=checkbuttons[checkbix], ...)

 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python3.6 tkinter bug?

2022-09-22 Thread Peter Smith
On Wednesday, February 1, 2017 at 11:55:35 AM UTC, Terry Reedy wrote:
> On 2/1/2017 1:37 AM, Christian Gollwitzer wrote: 
> > Am 01.02.17 um 00:02 schrieb MRAB: 
> >> On 2017-01-31 22:34, Christian Gollwitzer wrote: 
>  .!frame.!checkbutton 
>  .!frame.!checkbutton2 
>  .!frame2.!checkbutton 
>  .!frame2.!checkbutton2 
> >>> 
> >>> 
> >> Perhaps someone who knows Tcl and tk can tell me, but I notice that in 
> >> the first example, the second part of the widget names are unique, 
> >> whereas in the second example, the second part of the widget names are 
> >> the reused (both "!checkbutton" and "!checkbutton2" occur twice). 
> > 
> > It is indeed the reason, but it has some strange legacy cause: the 
> > default name for the checkbutton-linked variable is the name of the 
> > button inside the parent. Therefore creating a checkbutton has the side 
> > effect of creating a variable with the button's name. 
> > 
> > In this case, the first buttons in the frames are linked to a variable 
> > called "!checkbutton" and the other two are linked to "!checkbutton2". 
> > (a variable name in Tcl can be anything apart from the empty string). 
> > This can also be demonstrated by this Tcl script: 
> > 
> > package require Tk 
> > 
> > pack [frame .f1] 
> > pack [frame .f2] 
> > 
> > pack [checkbutton .f1.c1 -text "A" ] 
> > pack [checkbutton .f1.c2 -text "B" ] 
> > 
> > pack [checkbutton .f2.c1 -text "C" ] 
> > pack [checkbutton .f2.c2 -text "D" ] 
> > 
> > which is equivalent to the Python code above. 
> > 
> > Note that this surprising behaviour was corrected for the (modern) ttk 
> > widgets, so if "checkbutton" is replaced by "ttk::checkbutton", they are 
> > not any longer linked. In Python, that would be 
> > 
> > from tkinter import ttk 
> > ... 
> > w = ttk.Checkbutton() 
> > 
> > (Personally, I'm not using the legacy widgets any longer)
> Christian, could you repeat any relevant parts of your comments on the 
> tracker, especially any ideas on how we might fix tkinter? 
> https://bugs.python.org/issue29402
> >> Do the names need to be: 
> >> 
> >> .!frame.!checkbutton 
> >> .!frame.!checkbutton2 
> >> .!frame2.!checkbutton3 
> >> .!frame2.!checkbutton4
> Serhiy considered that but, not knowing that this would cause a 
> regression, we both liked numbering within parent better. 
> 
> There is a similar issue with radiobuttons on ttk.OptionMenus that 
> existed *before* the 3.6 name changes. 
> https://bugs.python.org/issue25684 
> So there seems to be a systematic issue with tk or how we are (mis)using it.
> > Good question. Maybe there should be unique variable names? I.e., if the 
> > script is changed into package require Tk 
> > 
> > pack [frame .f1] 
> > pack [frame .f2] 
> > 
> > pack [checkbutton .f1.c1 -text "A" -variable v1] 
> > pack [checkbutton .f1.c2 -text "B" -variable v2] 
> > 
> > pack [checkbutton .f2.c1 -text "C" -variable v3] 
> > pack [checkbutton .f2.c2 -text "D" -variable v4] 
> > 
> > then they are also not linked.
> -- 
> Terry Jan Reedy
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python3.6 tkinter bug?

2017-02-01 Thread Terry Reedy

On 2/1/2017 1:37 AM, Christian Gollwitzer wrote:

Am 01.02.17 um 00:02 schrieb MRAB:

On 2017-01-31 22:34, Christian Gollwitzer wrote:

.!frame.!checkbutton
.!frame.!checkbutton2
.!frame2.!checkbutton
.!frame2.!checkbutton2




Perhaps someone who knows Tcl and tk can tell me, but I notice that in
the first example, the second part of the widget names are unique,
whereas in the second example, the second part of the widget names are
the reused (both "!checkbutton" and "!checkbutton2" occur twice).


It is indeed the reason, but it has some strange legacy cause: the
default name for the checkbutton-linked variable is the name of the
button inside the parent. Therefore creating a checkbutton has the side
effect of creating a variable with the button's name.

In this case, the first buttons in the frames are linked to a variable
called "!checkbutton" and the other two are linked to "!checkbutton2".
(a variable name in Tcl can be anything apart from the empty string).
This can also be demonstrated by this Tcl script:

package require Tk

pack [frame .f1]
pack [frame .f2]

pack [checkbutton .f1.c1 -text "A" ]
pack [checkbutton .f1.c2 -text "B" ]

pack [checkbutton .f2.c1 -text "C" ]
pack [checkbutton .f2.c2 -text "D" ]

which is equivalent to the Python code above.

Note that this surprising behaviour was corrected for the (modern) ttk
widgets, so if "checkbutton" is replaced by "ttk::checkbutton", they are
not any longer linked. In Python, that would be

from tkinter import ttk
...
w = ttk.Checkbutton()

(Personally, I'm not using the legacy widgets any longer)


Christian, could you repeat any relevant parts of your comments on the 
tracker, especially any ideas on how we might fix tkinter?

https://bugs.python.org/issue29402


Do the names need to be:

.!frame.!checkbutton
.!frame.!checkbutton2
.!frame2.!checkbutton3
.!frame2.!checkbutton4


Serhiy considered that but, not knowing that this would cause a 
regression, we both liked numbering within parent better.


There is a similar issue with radiobuttons on ttk.OptionMenus that 
existed *before* the 3.6 name changes.

https://bugs.python.org/issue25684
So there seems to be a systematic issue with tk or how we are (mis)using it.


Good question. Maybe there should be unique variable names? I.e., if the
script is changed into package require Tk

pack [frame .f1]
pack [frame .f2]

pack [checkbutton .f1.c1 -text "A" -variable v1]
pack [checkbutton .f1.c2 -text "B" -variable v2]

pack [checkbutton .f2.c1 -text "C" -variable v3]
pack [checkbutton .f2.c2 -text "D" -variable v4]

then they are also not linked.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python3.6 tkinter bug?

2017-01-31 Thread Christian Gollwitzer

Am 01.02.17 um 00:02 schrieb MRAB:

On 2017-01-31 22:34, Christian Gollwitzer wrote:

.!frame.!checkbutton
.!frame.!checkbutton2
.!frame2.!checkbutton
.!frame2.!checkbutton2




Perhaps someone who knows Tcl and tk can tell me, but I notice that in
the first example, the second part of the widget names are unique,
whereas in the second example, the second part of the widget names are
the reused (both "!checkbutton" and "!checkbutton2" occur twice).


It is indeed the reason, but it has some strange legacy cause: the 
default name for the checkbutton-linked variable is the name of the 
button inside the parent. Therefore creating a checkbutton has the side 
effect of creating a variable with the button's name.


In this case, the first buttons in the frames are linked to a variable 
called "!checkbutton" and the other two are linked to "!checkbutton2". 
(a variable name in Tcl can be anything apart from the empty string). 
This can also be demonstrated by this Tcl script:


package require Tk

pack [frame .f1]
pack [frame .f2]

pack [checkbutton .f1.c1 -text "A" ]
pack [checkbutton .f1.c2 -text "B" ]

pack [checkbutton .f2.c1 -text "C" ]
pack [checkbutton .f2.c2 -text "D" ]

which is equivalent to the Python code above.

Note that this surprising behaviour was corrected for the (modern) ttk 
widgets, so if "checkbutton" is replaced by "ttk::checkbutton", they are 
not any longer linked. In Python, that would be


from tkinter import ttk
...
w = ttk.Checkbutton()

(Personally, I'm not using the legacy widgets any longer)


Do the names need to be:

.!frame.!checkbutton
.!frame.!checkbutton2
.!frame2.!checkbutton3
.!frame2.!checkbutton4


Good question. Maybe there should be unique variable names? I.e., if the 
script is changed into 	package require Tk


pack [frame .f1]
pack [frame .f2]

pack [checkbutton .f1.c1 -text "A" -variable v1]
pack [checkbutton .f1.c2 -text "B" -variable v2]

pack [checkbutton .f2.c1 -text "C" -variable v3]
pack [checkbutton .f2.c2 -text "D" -variable v4]

then they are also not linked.


Christian
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python3.6 tkinter bug

2017-01-31 Thread George Trojan - NOAA Federal
On 2017-01-31 18:02, MRAB wrote:

On 2017-01-31 22:34, Christian Gollwitzer wrote:
> >* Am 31.01.17 um 20:18 schrieb George Trojan - NOAA Federal:
> *>>* Selection of button 'A' also selects button 'C'. Same goes for 'B' and 
> 'D'.
> *>>* I noticed that widget names have changed, which likely leads to the 
> cause:
> *>>
> >>>* /usr/local/Python-3.5.1/bin/python3 foo.py
> *>>* .140182648425776.140182647743208
> *>>* .140182648425776.140182647841848
> *>>* .140182648424152.140182648282080
> *>>* .140182648424152.140182648282136
> *>>
> >>>* /usr/local/Python-3.6.0/bin/python3 foo.py
> *>>* .!frame.!checkbutton
> *>>* .!frame.!checkbutton2
> *>>* .!frame2.!checkbutton
> *>>* .!frame2.!checkbutton2
> *>
> >* The widget names look fine to, and the 3.6 naming is way better, because
> *>* it can be used for debugging more easily. The behaviour you describe can
> *>* have two reasons, a) the same widget can be packed twice b) the widgets
> *>* use the same variable. In Tk, a widget does not need an associate
> *>* variable - which can be done by setting the variable to an empty string,
> *>* or by leaving this option off.
> *>
> >* Presumably Python 3.6 passes anything else than an empty string to Tk as
> *>* the -variable option, maybe a mistranslated None? Can't test it myself,
> *>* but in your example you could, for instance, check the output of
> *>* self.call(w, 'configure'), which lists you the Tk side configuration, or
> *>* self.call(w, 'configure', '-variable') to get specifically the bound
> *>* variable.
> *>
> Perhaps someone who knows Tcl and tk can tell me, but I notice that in
> the first example, the second part of the widget names are unique,
> whereas in the second example, the second part of the widget names are
> the reused (both "!checkbutton" and "!checkbutton2" occur twice). Is
> that the cause?
> Do the names need to be:
> .!frame.!checkbutton
> .!frame.!checkbutton2
> .!frame2.!checkbutton3
> .!frame2.!checkbutton4
> ?


Adding dummy variable solves the issue. Following Christian's
suggestion I added code to print Tk variable:

from functools import partial
import tkinter

class GUI(tkinter.Tk):
def __init__(self):
tkinter.Tk.__init__(self)
frame = tkinter.Frame(self)
for tag in ('A', 'B'):
w = tkinter.Checkbutton(frame, text=tag, #
variable=tkinter.IntVar(),
command=partial(print, tag))
w.pack(side='top', padx=10, pady=10)
print(tag, self.call(w, 'configure', '-variable'))
print(w)
frame.pack(side='top')
frame = tkinter.Frame(self)
for tag in ('C', 'D'):
w = tkinter.Checkbutton(frame, text=tag, #
variable=tkinter.IntVar(),
command=partial(print, tag))
w.pack(side='top', padx=10, pady=10)
print(tag, self.call(w, 'configure', '-variable'))
print(w)
frame.pack(side='top')

gui = GUI()
gui.mainloop()

The output is:

(venv-3.6.0) dilbert@gtrojan> python foo.py
A ('-variable', 'variable', 'Variable', '', )
.!frame.!checkbutton
B ('-variable', 'variable', 'Variable', '', )
.!frame.!checkbutton2
C ('-variable', 'variable', 'Variable', '', )
.!frame2.!checkbutton
D ('-variable', 'variable', 'Variable', '', )
.!frame2.!checkbutton2

It looks like the default name is the last component of widget tree.

When the # sign is removed, the names are unique and the problem disappears:

(venv-3.6.0) dilbert@gtrojan> python foo.py
A ('-variable', 'variable', 'Variable', '', )
.!frame.!checkbutton
B ('-variable', 'variable', 'Variable', '', )
.!frame.!checkbutton2
C ('-variable', 'variable', 'Variable', '', )
.!frame2.!checkbutton
D ('-variable', 'variable', 'Variable', '', )
.!frame2.!checkbutton2
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python3.6 tkinter bug?

2017-01-31 Thread MRAB

On 2017-01-31 22:34, Christian Gollwitzer wrote:

Am 31.01.17 um 20:18 schrieb George Trojan - NOAA Federal:

Selection of button 'A' also selects button 'C'. Same goes for 'B' and 'D'.
I noticed that widget names have changed, which likely leads to the cause:


/usr/local/Python-3.5.1/bin/python3 foo.py

.140182648425776.140182647743208
.140182648425776.140182647841848
.140182648424152.140182648282080
.140182648424152.140182648282136


/usr/local/Python-3.6.0/bin/python3 foo.py

.!frame.!checkbutton
.!frame.!checkbutton2
.!frame2.!checkbutton
.!frame2.!checkbutton2


The widget names look fine to, and the 3.6 naming is way better, because
it can be used for debugging more easily. The behaviour you describe can
have two reasons, a) the same widget can be packed twice b) the widgets
use the same variable. In Tk, a widget does not need an associate
variable - which can be done by setting the variable to an empty string,
or by leaving this option off.

Presumably Python 3.6 passes anything else than an empty string to Tk as
the -variable option, maybe a mistranslated None? Can't test it myself,
but in your example you could, for instance, check the output of
self.call(w, 'configure'), which lists you the Tk side configuration, or
self.call(w, 'configure', '-variable') to get specifically the bound
variable.

Perhaps someone who knows Tcl and tk can tell me, but I notice that in 
the first example, the second part of the widget names are unique, 
whereas in the second example, the second part of the widget names are 
the reused (both "!checkbutton" and "!checkbutton2" occur twice). Is 
that the cause?


Do the names need to be:

.!frame.!checkbutton
.!frame.!checkbutton2
.!frame2.!checkbutton3
.!frame2.!checkbutton4

?

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python3.6 tkinter bug?

2017-01-31 Thread Christian Gollwitzer

Am 31.01.17 um 20:18 schrieb George Trojan - NOAA Federal:

Selection of button 'A' also selects button 'C'. Same goes for 'B' and 'D'.
I noticed that widget names have changed, which likely leads to the cause:


/usr/local/Python-3.5.1/bin/python3 foo.py

.140182648425776.140182647743208
.140182648425776.140182647841848
.140182648424152.140182648282080
.140182648424152.140182648282136


/usr/local/Python-3.6.0/bin/python3 foo.py

.!frame.!checkbutton
.!frame.!checkbutton2
.!frame2.!checkbutton
.!frame2.!checkbutton2


The widget names look fine to, and the 3.6 naming is way better, because 
it can be used for debugging more easily. The behaviour you describe can 
have two reasons, a) the same widget can be packed twice b) the widgets 
use the same variable. In Tk, a widget does not need an associate 
variable - which can be done by setting the variable to an empty string, 
or by leaving this option off.


Presumably Python 3.6 passes anything else than an empty string to Tk as 
the -variable option, maybe a mistranslated None? Can't test it myself, 
but in your example you could, for instance, check the output of 
self.call(w, 'configure'), which lists you the Tk side configuration, or 
self.call(w, 'configure', '-variable') to get specifically the bound 
variable.


Christian

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python3.6 tkinter bug?

2017-01-31 Thread Terry Reedy

On 1/31/2017 4:11 PM, Terry Reedy wrote:

On 1/31/2017 3:43 PM, MRAB wrote:

On 2017-01-31 19:18, George Trojan - NOAA Federal wrote:

The following program behaves differently under Python 3.6:

'''
checkbutton test
'''

import tkinter

class GUI(tkinter.Tk):
def __init__(self):
tkinter.Tk.__init__(self)
frame = tkinter.Frame(self)
for tag in ('A', 'B'):
w = tkinter.Checkbutton(frame, text=tag)
w.pack(side='top', padx=10, pady=10)
print(w)
frame.pack(side='top')
frame = tkinter.Frame(self)
for tag in ('C', 'D'):
w = tkinter.Checkbutton(frame, text=tag)
w.pack(side='top', padx=10, pady=10)
print(w)
frame.pack(side='top')

gui = GUI()
gui.mainloop()

Selection of button 'A' also selects button 'C'. Same goes for 'B' and
'D'.
I noticed that widget names have changed, which likely leads to the
cause:


/usr/local/Python-3.5.1/bin/python3 foo.py

.140182648425776.140182647743208
.140182648425776.140182647841848
.140182648424152.140182648282080
.140182648424152.140182648282136


/usr/local/Python-3.6.0/bin/python3 foo.py

.!frame.!checkbutton
.!frame.!checkbutton2
.!frame2.!checkbutton
.!frame2.!checkbutton2

Is this a known issue?


I don't believe so; at least, I couldn't see it in the bug tracker.


Me neither.  I will open an issue on the tracker.


https://bugs.python.org/issue29402


Presumably you'll want to check the values of the checkboxes, so you'll
bind them to tkinter variables (IntVar, etc). When you do that, it works
correctly.


This still seems like a bug to me.  Similar issue
https://bugs.python.org/issue25684 has the same workaround for ttk 
Option Menu radiobuttons.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python3.6 tkinter bug?

2017-01-31 Thread Terry Reedy

On 1/31/2017 3:43 PM, MRAB wrote:

On 2017-01-31 19:18, George Trojan - NOAA Federal wrote:

The following program behaves differently under Python 3.6:

'''
checkbutton test
'''

import tkinter

class GUI(tkinter.Tk):
def __init__(self):
tkinter.Tk.__init__(self)
frame = tkinter.Frame(self)
for tag in ('A', 'B'):
w = tkinter.Checkbutton(frame, text=tag)
w.pack(side='top', padx=10, pady=10)
print(w)
frame.pack(side='top')
frame = tkinter.Frame(self)
for tag in ('C', 'D'):
w = tkinter.Checkbutton(frame, text=tag)
w.pack(side='top', padx=10, pady=10)
print(w)
frame.pack(side='top')

gui = GUI()
gui.mainloop()

Selection of button 'A' also selects button 'C'. Same goes for 'B' and
'D'.
I noticed that widget names have changed, which likely leads to the
cause:


/usr/local/Python-3.5.1/bin/python3 foo.py

.140182648425776.140182647743208
.140182648425776.140182647841848
.140182648424152.140182648282080
.140182648424152.140182648282136


/usr/local/Python-3.6.0/bin/python3 foo.py

.!frame.!checkbutton
.!frame.!checkbutton2
.!frame2.!checkbutton
.!frame2.!checkbutton2

Is this a known issue?


I don't believe so; at least, I couldn't see it in the bug tracker.


Me neither.  I will open an issue on the tracker.


Presumably you'll want to check the values of the checkboxes, so you'll
bind them to tkinter variables (IntVar, etc). When you do that, it works
correctly.




--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python3.6 tkinter bug?

2017-01-31 Thread MRAB

On 2017-01-31 19:18, George Trojan - NOAA Federal wrote:

The following program behaves differently under Python 3.6:

'''
checkbutton test
'''

import tkinter

class GUI(tkinter.Tk):
def __init__(self):
tkinter.Tk.__init__(self)
frame = tkinter.Frame(self)
for tag in ('A', 'B'):
w = tkinter.Checkbutton(frame, text=tag)
w.pack(side='top', padx=10, pady=10)
print(w)
frame.pack(side='top')
frame = tkinter.Frame(self)
for tag in ('C', 'D'):
w = tkinter.Checkbutton(frame, text=tag)
w.pack(side='top', padx=10, pady=10)
print(w)
frame.pack(side='top')

gui = GUI()
gui.mainloop()

Selection of button 'A' also selects button 'C'. Same goes for 'B' and 'D'.
I noticed that widget names have changed, which likely leads to the cause:


/usr/local/Python-3.5.1/bin/python3 foo.py

.140182648425776.140182647743208
.140182648425776.140182647841848
.140182648424152.140182648282080
.140182648424152.140182648282136


/usr/local/Python-3.6.0/bin/python3 foo.py

.!frame.!checkbutton
.!frame.!checkbutton2
.!frame2.!checkbutton
.!frame2.!checkbutton2

Is this a known issue?


I don't believe so; at least, I couldn't see it in the bug tracker.

Presumably you'll want to check the values of the checkboxes, so you'll 
bind them to tkinter variables (IntVar, etc). When you do that, it works 
correctly.


--
https://mail.python.org/mailman/listinfo/python-list


Python3.6 tkinter bug?

2017-01-31 Thread George Trojan - NOAA Federal
The following program behaves differently under Python 3.6:

'''
checkbutton test
'''

import tkinter

class GUI(tkinter.Tk):
def __init__(self):
tkinter.Tk.__init__(self)
frame = tkinter.Frame(self)
for tag in ('A', 'B'):
w = tkinter.Checkbutton(frame, text=tag)
w.pack(side='top', padx=10, pady=10)
print(w)
frame.pack(side='top')
frame = tkinter.Frame(self)
for tag in ('C', 'D'):
w = tkinter.Checkbutton(frame, text=tag)
w.pack(side='top', padx=10, pady=10)
print(w)
frame.pack(side='top')

gui = GUI()
gui.mainloop()

Selection of button 'A' also selects button 'C'. Same goes for 'B' and 'D'.
I noticed that widget names have changed, which likely leads to the cause:

> /usr/local/Python-3.5.1/bin/python3 foo.py
.140182648425776.140182647743208
.140182648425776.140182647841848
.140182648424152.140182648282080
.140182648424152.140182648282136

> /usr/local/Python-3.6.0/bin/python3 foo.py
.!frame.!checkbutton
.!frame.!checkbutton2
.!frame2.!checkbutton
.!frame2.!checkbutton2

Is this a known issue?

George
-- 
https://mail.python.org/mailman/listinfo/python-list