[Tkinter-discuss] tk 8.3 and unicode

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Wed Jun 1 13:42:23 CEST 2005


Jeff Epler wrote:
> This bug must have been fixed between Python 2.2 + Tk 8.3 and Python 2.3
> + Tk 8.4.
> 
> Running a slightly different test program, I get this output on Fedora
> Core 1 (Python 2.2 + Tk 8.3):
>     '\xc2\xa3'
> and this output on Fedora Core 2 (Python 2.3 + Tk 8.4):
>     u'\xa3'
> 
> You could try defining a
>     class UStringVar(Tkinter.StringVar):
>         def get(self):
>             return Tkinter.StringVar.get(self).decode("utf-8")
> and using that instead.  This seemed to work on the FC1 system, at least
> when LANG=en_US.UTF-8 -- this might depend on tcl's idea of the sytem
> encoding, though.
> 

Thanks Jeff,

The call to decode() when I get the entry's textvariable does indeed fix
the problem.  I now have a similar (but wholly different;-) problem
related to a filename containing a Unicode character, however, I think
I'll resolve this but not allowing my users to do this (I believe it is
dependent on more than just Python / Tk - It must involve the OS at some
level)

Cheers,
Martin.



More information about the Tkinter-discuss mailing list