G
Guest
Just curious if anyone could shed some light on this? I'm using
tkinter, but I can't seem to get certain unicode characters to
show in the label for Python 3.
In my test, the label and button will contain the same 3
characters - a Greek Alpha, a Greek Omega with a circumflex and
soft breathing accent, and then a Greek Alpha with a soft
breathing accent.
For Python 2.6, this works great:
# -*- coding: utf-8 -*-
from Tkinter import *
root = Tk()
Label(root, text=u'\u03B1 \u1F66 \u1F00').pack()
Button(root, text=u'\u03B1 \u1F66 \u1F00').pack()
root.mainloop()
However, for Python 3.1.2, the button gets the correct characters,
but the label only displays the first Greek Alpha character.
The other 2 characters look like Chinese characters followed by
an empty box. Here's the code for Python 3:
# -*- coding: utf-8 -*-
from tkinter import *
root = Tk()
Label(root, text='\u03B1 \u1F66 \u1F00').pack()
Button(root, text='\u03B1 \u1F66 \u1F00').pack()
root.mainloop()
I've done some research and am wondering if it is
because Python 2.6 comes with tk version 8.5, while Python 3.1.2
comes with tk version 8.4? I'm running this on OS X 10.6.4.
Here's a link I found that mentions this same problem:
http://www.mofeel.net/871-comp-lang-python/5879.aspx
If I need to upgrade tk to 8.5, is it best to upgrade it or just
install 'tiles'? From my readings it looks like upgrading to
8.5 can be a pain due to OS X still pointing back to 8.4. I
haven't tried it yet in case someone might have an easier
solution.
Thanks for looking at my question.
Jay
tkinter, but I can't seem to get certain unicode characters to
show in the label for Python 3.
In my test, the label and button will contain the same 3
characters - a Greek Alpha, a Greek Omega with a circumflex and
soft breathing accent, and then a Greek Alpha with a soft
breathing accent.
For Python 2.6, this works great:
# -*- coding: utf-8 -*-
from Tkinter import *
root = Tk()
Label(root, text=u'\u03B1 \u1F66 \u1F00').pack()
Button(root, text=u'\u03B1 \u1F66 \u1F00').pack()
root.mainloop()
However, for Python 3.1.2, the button gets the correct characters,
but the label only displays the first Greek Alpha character.
The other 2 characters look like Chinese characters followed by
an empty box. Here's the code for Python 3:
# -*- coding: utf-8 -*-
from tkinter import *
root = Tk()
Label(root, text='\u03B1 \u1F66 \u1F00').pack()
Button(root, text='\u03B1 \u1F66 \u1F00').pack()
root.mainloop()
I've done some research and am wondering if it is
because Python 2.6 comes with tk version 8.5, while Python 3.1.2
comes with tk version 8.4? I'm running this on OS X 10.6.4.
Here's a link I found that mentions this same problem:
http://www.mofeel.net/871-comp-lang-python/5879.aspx
If I need to upgrade tk to 8.5, is it best to upgrade it or just
install 'tiles'? From my readings it looks like upgrading to
8.5 can be a pain due to OS X still pointing back to 8.4. I
haven't tried it yet in case someone might have an easier
solution.
Thanks for looking at my question.
Jay