how to display unicode in a Label in Tkinter
Ben Last
ben at benlast.com
Tue Aug 17 08:46:02 EDT 2004
Ali wrote:
> > So how I write in Arabic?
Eric answered:
> There must be another simpler way, based on the standard encoding
> used when
> using Arabic characters. But I don't know this encoding, so I
> cannot help you
> much here. I also don't know how you can input these characters
> in a computer
> (especially in a source file, where the character flow is from
> left to right)
The easiest way I have found to have Unicode strings is not to embed them in
the source at all, because every so often I'll find that I've passed my
source through a Python editor or tool that doesn't grok encodings and all
my embedded characters have been mangled. Instead, I write the Unicode
strings in an editor (such as the humble Notepad) that supports saving UTF8
files, and save them that way, usually in a simple "keyword=value" format so
that my Python code can open up the file, read in the strings, decode them
from UTF-8 and there's your Unicode all available.
To echo other comments, though, AFAIK, TkInter doesn't do non-Western
languages very well, if at all. A contact of mine has reported more success
with wxPython, but the projects I'm on now don't venture outside the Latin
encodings, so I can't advise as to whether Arabic is supported.
Having moaned somewhat there; I have to say that Python has about the sanest
Unicode handling of any environment I've yet had to use in anger... I
learned i18n in C on VAX/VMS systems, the hard way...
regards
ben
More information about the Python-list
mailing list