Help: Chinese charactor in Tkinter

jepler epler jepler.lnk at lnk.ispi.net
Sat Sep 30 16:48:57 EDT 2000


On Sat, 30 Sep 2000 00:16:53 -0400, Zhenlei Jia
 <zj8k at node14.unix.Virginia.EDU> wrote:
>I am trying to display Chinese charactor in Tkinter. The following is 
>the code I've tried, but the texts were displied as "?". Had I missed
>somthing, or just I can't do it on my system? I am using MacPython 2.0b1,
>Tcl & Tk 8.3.0 on MacOS 8.6, I have installed Chinese Language Kit, and I
>can display Chinese char in java, also using unicode.

In tcl, strings are converted from various character sets to the
"system encoding" by way of the command "encoding convertfrom".

This appears to be supported internally by Python in Modules/_tkinter.c:
AsObj() (the block if (PyUnicode_Check(value)) ...), so I'm not sure
why this doesn't work.  I would test this out myself, but the version
of tk I have installed here (8.0) is too old to support unicode.

If you can execute tk's "wish" program directly, try running the following
code:
	button .b -text \u5413abcd -font {Song -12}
if you can see the chinese character now, the fault lies somewhere
within Python; if not, the fault lies somewhere within tk.

Jeff



More information about the Python-list mailing list