Tkinter disregards font encoding
Martin v. Löwis
loewis at informatik.hu-berlin.de
Mon Nov 4 03:21:57 EST 2002
hjwidmaier at web.de (Hans-Joachim Widmaier) writes:
> My code's like this:
> Font = '-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-iso8859-15'
>
> w = Label(master, font=Font, textvariable=self.priceVar,
> justify=RIGHT)
>
> But I do not get the expected Euro sign; Tk uses definitely the
> *-iso8859-1 variant. The -15 is installed, I can use it with other
> applications and look at it with xfd.
What is the value of self.priceVar?
> Does anyone have an idea how I might circumvent that problem?
Here is my theory: you are using a Latin-1 locale, and use a byte
string for the priceVar, where you use '\xe4' to denote the EURO SIGN.
However, in Latin-1, '\xe4' denotes the CURRENCY SIGN. Tk tries to
convert the local encoding (latin-1) into the font encoding (latin-9);
since latin-9 does not support the CURRENCY SIGN, this conversion
fails.
Instead, you should use a Unicode string to denote the EURO SIGN,
which would be u'\u20ac'.
HTH,
Martin
More information about the Python-list
mailing list