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

Michael Lange klappnase at web.de
Tue Jun 12 19:04:04 CEST 2012


Hi,

Thus spoketh Cameron Laird <Cameron at phaseit.net> 
unto us on Tue, 12 Jun 2012 12:16:22 +0000:

> 			.
> <URL: http://docs.python.org/release/2.5.2/lib/truth.html >

hmm, but this does not seem to apply to Tkinter, for example

>>> root.overrideredirect([])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1571, in
wm_overrideredirect 'wm', 'overrideredirect', self._w, boolean))
_tkinter.TclError: expected boolean value but got "[]"
>>> root.overrideredirect(0j)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1571, in
wm_overrideredirect 'wm', 'overrideredirect', self._w, boolean))
_tkinter.TclError: expected boolean value but got "0j"
>>> root.overrideredirect('')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1571, in
wm_overrideredirect 'wm', 'overrideredirect', self._w, boolean))
_tkinter.TclError: expected boolean value but got ""

but:

>>> root.overrideredirect(0.0)
>>> root.overrideredirect(0L)
>>> root.overrideredirect(55)
>>> 

whereas:

>>> getboolean(0.0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.1/tkinter/__init__.py", line 328, in getboolean
    return _default_root.tk.getboolean(s)
TypeError: must be string, not float
>>> getboolean(0L)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 336, in getboolean
    return _default_root.tk.getboolean(s)
TypeError: getboolean() argument 1 must be string, not long

so it actually looks like Tkinter behavior is not fully coherent here.

Regards

Michael

.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

I thought my people would grow tired of killing.  But you were right,
they see it is easier than trading.  And it has its pleasures.  I feel
it myself.  Like the hunt, but with richer rewards.
		-- Apella, "A Private Little War", stardate 4211.8


More information about the Tkinter-discuss mailing list