Cyrillic character usage in Tkinter
Martin v. Löwis
loewis at informatik.hu-berlin.de
Wed Nov 6 11:53:06 EST 2002
"Bobirkhon Ismailov" <bismailov at uzavtoyul.uz> writes:
> I'd like to use Cyrillic (Russian) letters in Tkinter (that comes with
> Python 2.1.1 in Windows), but the text that comes up in widgets is not
> readable. I will really appreciate if somebody shows me how to print
> Cyrillic in Tkinter.
The best approach is to use Unicode strings. Please try running the
script
import Tkinter
t = Tkinter.Label(text=u'\N{CYRILLIC SMALL LETTER ZHE}\u0437')
t.pack()
t.tk.mainloop()
If you want to use some byte encoding, such as CP 1251, in your source
code, you should write
t = Tkinter.Label(text=unicode("cyrillic text here", "cp1251"))
Notice that editing such source code in IDLE is currently not
supported (unless you change the default encoding), so you need to use
a different editor, eg. notepad.exe.
HTH,
Martin
More information about the Python-list
mailing list