[Python-Dev] Tkinter problems with Tcl/Tk 8.5
"Martin v. Löwis"
martin at v.loewis.de
Tue Jan 1 22:18:51 CET 2008
> It seems very peculiar how the text widget's bbox is returning a
> Python-like list and therefore breaking the Tcl callback. I haven't
> thus far been able to determine which python method is causing that,
> or if it's something related to the hooks you have added. The same
> problem doesn't occur with 8.4.
I have now studied this in detail, and fixed it in Python's trunk;
see the tracker item for details.
In short:
- IDLE redirects all widget sub-commands, either calling an overridden
definition, or the original Tk command.
- in the redirection of "bbox", Tk 8.4 would return a string, whereas
8.5 now returns a list.
- _tkinter converts the string to a Python string, and the list to a
Python tuple
- IDLE returns the Python value to _tkinter, which in turn converts
it to a string. This leaves the 8.4 string unchanged, but converts
the 8.5 tuple into something like "(10, 10, 20, 20)".
- Tk interprets it as a list of numbers, choking as "(10," is not
a meaningful number.
The fix is to return an ObjResult to Tcl from a Python callback.
I'm skeptical about back-porting this to 2.5, as it may affect behavior.
So for 2.5, we probably have to recommend not using Tk 8.5.
There are a number of additional incompatible changes. For example,
text::index returns textindex objects now, where it used to return
strings. I have fixed that in Tkinter, which converts the textindex
back to a string. I'm sure there are other places where Tk 8.5 will
break existing Tkinter applications.
Regards,
Martin
More information about the Python-Dev
mailing list