Problem with Tkinter and some Kanji unicode values.

R

Read Roberts

Has any one else seen the following?

Mac OSX 10.3.6, standard Python from 10.3.4 installation + tkAqua
Tkinter.tkinter.TK_VERSION is '8.4'

I set a unicode string into a tKinter widget. Some kanji display
correctly, some do not. The ones that don't show up as a white square
followed by a black square. The font used by the widgets does contain
glyphs for all the Unicode values in the test string.

I can copy and text from the Entry widget, and paste it elsewhere,
and see that i still get the correct Unicode values, so the problem
is one of display rather than encoding conversion.

from Tkinter import *
from tkFont import Font as TKFont
root = Tk()
root.font = TKFont(root, font =
(u'\u30d2\u30e9\u30ae\u30ce\u89d2\u30b4 Pro W3', 12))
print root.font.actual()
myFrame = Frame(root)
root.resizable(1, 1)
root.rowconfigure(0,weight=1)
root.columnconfigure(0,weight=1)
myFrame.grid()
myFrame.rowconfigure(0,weight=1)
myFrame.columnconfigure(0,weight=1)
myEntry = Entry(myFrame, borderwidth = 10, font=root.font)
testString = u"\u8146, \u500e, \u440c"
myEntry.insert(0, testString)
myEntry.grid()
print repr(myEntry.get())
myFrame.mainloop()

The font is used in this example is Hiragino Kaku Gothic-W3.
FontBook shows that it has glyphs for all three Unicode values in the
test string. u8146 shows up correctly, the others do not. Works
fine on Windows.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top