Python 2.3b1 and _tkinter.Tcl_Obj
Martin v. Löwis
martin at v.loewis.de
Wed Apr 30 15:28:27 EDT 2003
"Stephen D Evans" <sde at recombinant.demon.co.uk> writes:
> Is this Python or Tk/Tcl? Is it a bug or a feature?
>
> There are some inconsistencies in the types returned by some Tkinter widgets
> when using cget() or configure() e.g.
> widget.cget('background')
> Menu widgets return a Tcl_Obj (typename='border'), Buttons return a string.
The inconsistency is in Tk. Tk widgets can chose whether they use the
Tcl object API or the Tcl string API; apparently, some widgets chose
one API, and other widgets the other.
If this is a problem for you, you have the following options:
- set Tkinter.wantobjects to False before creating the first
tkapp object. This will give you the Python 2.2 behaviour.
- convert Tcl_Obj objects to strings using str()
- convert Tcl_Obj objects to Unicode using unicode()
- convert Tcl_Obj objects using
ASCII-if-possible-otherwise-Unicode-if-possible-otherwise-bytes
algorithm of Python 2.2 using Tcl_Obj.string
If you feel you need to take one of these approaches, please let us
know, so we can see whether backwards compatibility needs to be
improved.
Regards,
Martin
More information about the Python-list
mailing list