[Tkinter-discuss] Strange behavior with python 2.5

Vasilis Vlachoudis Vasilis.Vlachoudis at cern.ch
Sun Nov 16 19:59:48 CET 2008

Finally I didn't understand, is it a problem of Tkinter or Tk/Tcl? In
any case it breaks the behavior of many programs. Moreover returning a
different object after calling askdirectory it means that there is a
problem somewhere that changes the default behavior. Apart from type
casting with str() what is the correct solution?


-----Original Message-----
From: tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org
[mailto:tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org]
On Behalf Of Guilherme Polo
Sent: Sunday, 16 November 2008 17:04
To: Michael Lange; tkinter-discuss at python.org
Subject: Re: [Tkinter-discuss] Strange behavior with python 2.5

On Sun, Nov 16, 2008 at 12:43 PM, Michael Lange <klappnase at web.de>
> On Sat, 15 Nov 2008 19:41:39 -0200
> "Guilherme Polo" <ggpolo at gmail.com> wrote:
>> When you get a _tkinter.Tcl_Obj it means _tkinter wasn't able to
>> detect and convert a received tcl object to a python object. When
>> happens the best you can do is get the string representation of the
>> object by doing str(ans2) and then convert the value yourself (if you
>> want to convert it to something else different than a string).
>> With Tcl/Tk 8.5 and the current _tkinter you will see this happening
>> very often, as tcl/tk now shares objects as much as it can. _tkinter
>> checks for some specific tcl types but since it may receive any kind
>> of object, like a pixel object, or bytecode object which are part of
>> tcl (which happens to contain the same representation, that is why
>> they got shared) it ends up returning this generic Tcl_Obj.
> I also found this behavior quite often with Tk-8.4 on several linux
> in fact it seemed to me like it is impossible to predict when it will
> so unfortunately the only thing which seems to work reliably is
> Tkinter.wantobjects to False.

Setting wantobjects to False is broken in py3k tho.

It incurs performance penalty too, since you will be working with
strings only and objects won't be shared. At the same time it saves
some time in not needing to do any transformations, or any extra
attempts to transform, since it will always be a string but I don't
believe this gain shadows the loses.

> Michael
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss

-- Guilherme H. Polo Goncalves
Tkinter-discuss mailing list
Tkinter-discuss at python.org

More information about the Tkinter-discuss mailing list