Tkinter - non-ASCII characters in text widgets problem
spconv+m at gmail.com
Thu Jun 25 21:02:48 CEST 2009
I'm writing an application in Python 2.5.4 under Windows (xp sp3 en).
I use Tkinter as the main GUI toolkit. The app is intended to be
portable (not fully but win & mac os x is a must). It works as it
should on my system, but when I've sent the program to my friend who
has a mac computer, he told me accented characters are turned into
weird symbols. It is another must, the GUI consists of widgets with
polish characters. I always use UTF-8 encoding in Python and I save my
scripts in Notepad++ as UTF-8 without BOM. I've never experienced
similar problems under Windows with Tkinter before
I've created a simple test script:
# -*- coding: utf-8 -*-
from Tkinter import *
root = Tk()
No problem on Windows, but on mac Button widget has correct text.
Label and Entry has garbage instead of accented characters. (Mac OS X
10.5.6 and 10.4.11 both armed with Python 2.5.4)
I've tried various UTF file encoding (also with BOM mark), use of
u"text" or unicode() function - non of this worked. Googling shows not
root = Tk()
root.tk.call('encoding', 'system', 'utf-8')
After applying this, the effect remains the same - one big garbage.
I'm out of ideas: my script is UTF-8 in 101%; Mac and Windows both
support UTF-8, Python also supports it - so where is the problem? How
can I show mac-users polish signs?
More information about the Python-list