Python3.6 tkinter bug?

Terry Reedy tjreedy at udel.edu
Tue Jan 31 16:38:09 EST 2017


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



More information about the Python-list mailing list