Python3.6 tkinter bug?

Christian Gollwitzer auriocus at gmx.de
Tue Jan 31 17:34:22 EST 2017


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



More information about the Python-list mailing list