[Tkinter-discuss] Is it safe to use True/False for 1/0 in tkinter?

Cameron Laird Cameron at phaseit.net
Wed Jun 13 14:53:11 CEST 2012


On Wed, Jun 13, 2012 at 11:13:09AM +0200, Michael Lange wrote:
			.
			.
			.
> Let's try another Tk method that wants a boolean:
> 
> >>> root.tk_strictMotif(0.0)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 374, in tk_strictMotif
>     'set', 'tk_strictMotif', boolean))
> TypeError: getboolean() argument 1 must be string, not float
> >>> 
> 
> And when we look at what goes on behind the scenes:
> 
>     def tk_strictMotif(self, boolean=None):
>         """Set Tcl internal variable, whether the look and feel
>         should adhere to Motif.
> 
>         A parameter of 1 means adhere to Motif (e.g. no color
>         change if mouse passes over slider).
>         Returns the set value."""
>         return self.tk.getboolean(self.tk.call(
>             'set', 'tk_strictMotif', boolean))
> 
> we see that it's Tk itself which is not consistent, because
> tk_strictMotif apparently returns the float where wm overrideredirect
> does not.
			.
			.
			.
Within Tk, tk_strictMotif definitely takes on values 0
and 1.  I have no idea where the float emerges, nor the
time now to look into the Tkinter interface.


More information about the Tkinter-discuss mailing list