[Tkinter-discuss] Python2.5.1+Tkinter+Tile0.8.2

Guilherme Polo ggpolo at gmail.com
Mon Jan 12 22:47:57 CET 2009


On Mon, Jan 12, 2009 at 7:31 PM, Guilherme Polo <ggpolo at gmail.com> wrote:
> On Mon, Jan 12, 2009 at 7:16 PM, Guilherme Polo <ggpolo at gmail.com> wrote:
>> On Mon, Jan 12, 2009 at 6:17 PM, Russell E. Owen <rowen at u.washington.edu> wrote:
>>> In article <20090112154035.GA11443 at lairds.us>,
>>>  Cameron Laird <Cameron at phaseit.net> wrote:
>>>
>>>> On Fri, Jan 02, 2009 at 04:17:29PM +0000, Nawal <Galileon> Husnoo wrote:
>>>>                       .
>>>>                       .
>>>>                       .
>>>> > I'm just starting out in Python Tkinter programming, and I tried to use the
>>>> > Tile module to improve the looks of the Tk program I am writing.
>>>> >
>>>> > When I run the script written in <code></code> below, it works fine, using
>>>> > the Tile module to make the Tk look ok. However, when I try to use
>>>> > tkMessageBox.showwarning() as in the script, it fails with the error below.
>>>> > I've tried to cat | grep for "background" in the files mentionned in the
>>>> > error, but nothing turns up. I can't find where the "-background" switch is
>>>> > getting stuck in. I know the "background" switch doesn't work with Tile, but
>>>> > I can't find it to remove it. Any ideas please?
>>>>
>>>> Can you upgrade to 8.5 of Tk?  <URL:
>>>> http://tkinter.unpythonic.net/wiki/tk85_and_python >
>>>> might help you.
>>>
>>> Is that safe? I thought Python 2.5 was not fully compatible with Tcl/Tk
>>> 8.5.
>>>
>>
>> For some values of Python 2.5, yes.
>> Python 2.5.3 should have no problems with it, but I can't really say
>> you are wrong because I (think) there was another issue related to
>> Python 2.5.x and Tk 8.5 but I can't remember. I will try to find it
>> now.
>
> 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:
> http://svn.python.org/view/python/trunk/Modules/_tkinter.c?rev=59653&view=diff&r1=59653&r2=59652&p1=python/trunk/Modules/_tkinter.c&p2=/python/trunk/Modules/_tkinter.c
>
> 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.

-- 
-- Guilherme H. Polo Goncalves


More information about the Tkinter-discuss mailing list