From: jyoung79 on
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
From: Ned Deily on
In article <20100727204532.R7GMZ.27213.root(a)cdptpa-web20-z02>,
<jyoung79(a)kc.rr.com> wrote:
> 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.

Most likely. Apparently you're using the Apple-supplied Python 2.6
which, as you say, uses Tk 8.5. If you had installed the python.org
2.6, it would likely fail for you in the same way as 3.1, since both use
Tk 8.4. (They both fail for me.)

> 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.

OS X 10.6 comes with both Tk 8.4 and 8.5. The problem is that the
Python Tkinter(2.6) or tkinter(3.1) is linked at build time, not install
time, to one or the other. You would need to at least rebuild and
relink tkinter for 3.1 to use Tk 8.5, which means downloading and
building Python from source. New releases of python.org installers are
now coming in two varieties: the second will be only for 10.6 or later
and will link with Tk 8.5. The next new release of Python 3 is likely
months away, though. In the meantime, a simpler solution might be to
download and install the ActiveState Python 3.1 for OS X which does use
Tk 8.5. And your test case works for me with it.

--
Ned Deily,
nad(a)acm.org