Tkinter and locale
Fredrik Juhlin
laz at strakt.com
Mon Jan 14 06:03:59 EST 2002
Hello,
I have a problem with Tkinter and charsets that I just can't wrap my head
around:
Normally, I have the environment variable LC_CTYPE set to
"sv_SE.iso-8859-1" to be able to use latin1 chars in various programs.
It seems, however, as if TK does not like this, because it makes it
impossible for me to enter latin1 chars in i.e. entry widgets (pasting
them in works just fine, though).
I experimented for a while and soon found that if I just set LC_CTYPE to
"C" instead, TK worked just great.
This is where I get confused:
* Why wouldn't TK work properly with my original setting?
And even more confusing:
* Why _would_ TK work with LC_CTYPE=C? From what I've understood from the
man pages, C is 7-bit ASCII and if anything should not understand
latin1 characters.
Does anyone have a solution to this to make TK behave as expected?
I've enclosed some code below for testing.
//FJ
# Test locale settings with Tkinter
import Tkinter
import locale
## Switch which of the below lines are commented for testing
locale.setlocale(locale.LC_CTYPE, "sv_SE.iso-8859-1")
#locale.setlocale(locale.LC_CTYPE, "C")
print "Locale:", locale.getlocale()
root = Tkinter.Tk()
entry = Tkinter.Entry(root)
entry.pack()
Tkinter.mainloop()
More information about the Python-list
mailing list