ggpolo at gmail.com
Tue Jan 13 00:12:56 CET 2009
On Mon, Jan 12, 2009 at 7:57 PM, Guilherme Polo <ggpolo at gmail.com> wrote:
>>> Just found it. If you have the privilege of being able to run an
>>> own-compiled-version of Python (or, if possible, just update to Python
>>> 2.6), you could apply the following patch:
>>> That one wasn't backported to python 2.5, but I also don't remember
>>> how to exactly hit the bug -- but will try reproducing it here (this
>>> also remembers me of going back to finish the another python <->
>>> tcl/tk bridge).
>> Ah, yes:
>> import Tkinter
>> text = Tkinter.Text()
>> text.insert('end', 'hi there')
>> def test(x):
>> print x, type(x), "< bad"
>> text.tk.createcommand("test", test)
>> text.tk.call("test", text.bbox('1.0'))
>> x = text.bbox('1.0')
>> print x, type(x)
>> This is specially problematic in IDLE, but can affect other code too.
>> The problem is that bbox is supposed to return a tuple in Python,
>> which it returns, but then _tkinter (in Python 2.5) is not doing
>> proper object conversions in callbacks and you end up getting a string
>> in the example.
> Eh.. that wasn't the actual problem, give me some time :P
Trying a bit more I found this one:
root = Tkinter.Tk()
return (1, 2, 3)
x = root.tk.call("test")
print x, type(x)
With tk8.4 this returns a str, with tk8.5 and python 2.5.2 this
happens too, but with tk8.5 and python 2.6 it returns a tuple.
I believe this must cause trouble when using tk 8.5 specifically
because of other conversions errors, not this one alone, which didn't
happen with tk 8.4. To check something that gives you the problem, run
EditorWindow.py (in idlelib) then press 'a' and then tab for
autocomplete, it should hit the bug while using python 2.5 and tk 8.5.
-- Guilherme H. Polo Goncalves
More information about the Tkinter-discuss