Special characters (unicode) in wxPython widgets.

Hi,

I have buttons which, when clicked, should cause a unison or intersect symbol to appear in a textctrl.

I have managed to put the unison and intersect labels on the buttons themselves, but when the event handler tries to add a symbol to the textctrl, I get this exception:

UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\u2229’ in position 0: ordinal not in range(128)

How can I make it so that the TextCtrl accepts the Unicode characters?

Thank you,

Eric

Hi,

        I

have buttons which, when clicked, should cause a unison or
intersect symbol to appear in a textctrl.

        I

have managed to put the unison and intersect labels on the
buttons themselves, but when the event handler tries to add
a symbol to the textctrl, I get this exception:

        UnicodeEncodeError:

‘ascii’ codec can’t encode character u’\u2229’ in position
0: ordinal not in range(128)

        How

can I make it so that the TextCtrl accepts the Unicode
characters?

        Thank

you,

Eric

And, as always, if that doesn't help then please make a runnable, small as possible, sample application that demonstrates the problem, attach it to your mail, and let us know the platform and wx version. MakingSampleApps - wxPyWiki

···

On 8/19/11 1:00 PM, Gadget/Steve wrote:

On 19/08/2011 8:48 PM, Eric Zhao wrote:

Hi,

I have buttons which, when clicked, should cause a unison or intersect
symbol to appear in a textctrl.

I have managed to put the unison and intersect labels on the buttons
themselves, but when the event handler tries to add a symbol to the
textctrl, I get this exception:

UnicodeEncodeError: 'ascii' codec can't encode character u'\u2229' in
position 0: ordinal not in range(128)

How can I make it so that the TextCtrl accepts the Unicode characters?

You need to make sure that you are using the Unicode build of python and
wxPython I suspect that you might be using Ascii components.

--
Robin Dunn
Software Craftsman