[Tutor] Unicode and fonts in Idle and Tkinter

Emmanuel Ruellan emmanuel.ruellan at laposte.net
Fri Jun 13 03:46:19 CEST 2008


Hi all,

I'd like to display symbols from the international phonetic alphabet
(IPA) in a Tkinter window, but I do not manage to have them displayed
correctly, neither in a Tkinter window nor in Idle.

For example, I'd like to print the following string and get the result below:

*string*
my_text = u"""schwa: \N{latin small letter schwa}
open e: \N{LATIN SMALL LETTER OPEN E}
greek epsilon: \N{greek small letter epsilon}
retroflex d: \N{LATIN SMALL LETTER D WITH TAIL}
rhotacized schwa: \N{LATIN SMALL LETTER SCHWA WITH HOOK}
voiced lateral fricative: \N{LATIN SMALL LETTER LEZH}
low central unrounded vowel: \N{LATIN SMALL LETTER TURNED A}"""

*expected result*
schwa: ə
open e: ɛ
greek epsilon: ε
retroflex d: ɖ
rhotacized scwha: ɚ
voiced lateral fricative: ɮ
low central unrounded vowel: ɐ


I'm getting the expected result when I execute a script from the
shell, but in Idle (with font Times) and in a Tkinter window, I'm
getting this instead:

schwa: ə
open e: \u025b
greek epsilon: ε
retroflex d: \u0256
rhotacized scwha: \u025a
voiced lateral fricative: \u026e
low central unrounded vowel: ɐ

Some symbols get replaced by "\u02XX".

Note that the IPA open e and the Greek epsilon actually have the same
shape (glyph?) but the latter gets displayed correctly in Idle why the
former doesn't.

It may be just a font problem: when I try and change the font in Idle,
the result is different. That is, things are getting worse, not better
than with Times...

Can you advise on a font that works well for Unicode (more
specifically, IPA symbols) with Tkinter? preferably on both Windows
and Linux. BTW, how come I do not have the same set of fonts available
for Idle and for the shell?

I'm using Ubuntu (Hardy). My locale is utf-8. For the shell, I'm using
the Gnome terminal.

Emmanuel Ruellan


More information about the Tutor mailing list