Python3.6 tkinter bug?

MRAB python at mrabarnett.plus.com
Tue Jan 31 15:43:14 EST 2017


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.



More information about the Python-list mailing list