displaying unicode chars in combobox

In my app, If I paste Korean characters into the text
area of a combo box, press enter, and the combo box
uses the textenter event to read the pasted text and
insert it into the list box area, then the following
happens:
1)
the korean characters display fine in the text area
2)
after copying them to the list box area and pulling
down the menu, the characters appear as little
squares.

This does not happen if I paste bulgarian, chinese,
russian, or other characters available in the wxpython
demo.

If I paste Korean characters into a listctrl or a
textctrl of the app, they display with no problems.

Why would the korean characters display properly
everywhere except within a listbox?

I tried to reproduce in the wxpython demo by modifying
the combobox demo so that it uses the same technique
as the app to insert characters from the text area
into the list. But this worked just fine!

When I display the locale and default codec in the
demo and in my application, they both show:

Locale is: ('en_CA', 'cp1252'), Default Codec is:
'cp1252'

I'm using Windows XP SP2, wxpython 2.6.3.3 (unicode
version) and python 2.4.4
The demo is for 2.6.3.3

If anyone has any ideas on what could be happening and
how to fix it, i'd really appreciate it.

Thanks,

Jeremy.

···

____________________________________________________________________________________
Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545433

jeremy alexander wrote:

I tried to reproduce in the wxpython demo by modifying
the combobox demo so that it uses the same technique
as the app to insert characters from the text area
into the list. But this worked just fine!

Then there must be something different about your app. Try to narrow down the differences between it an the demo and you may find the source of the problem.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

I found out what was different!
The problem occurs if the font of the listbox is
changed. The following sample program can be used to
demonstrate:

···

=======================================================
import wx

class DisplayComboBoxPanel(wx.Panel):
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, id)

        self.itemlist = ['test1',
                         'test2',
                        ]
        self.rb = wx.ComboBox(
            self, -1, "", (-1,-1), (-1,-1),
self.itemlist, wx.CB_DROPDOWN)

        self.Bind(wx.EVT_TEXT_ENTER,
self.EvtTextEnter, self.rb)

        # change font size
        font = self.rb.GetFont()
        points = self.rb.GetFont().GetPointSize()
        family = self.rb.GetFont().GetFamily()
        style = self.rb.GetFont().GetStyle()
        weight = self.rb.GetFont().GetWeight()
        encoding = self.rb.GetFont().GetEncoding()
        bgc = self.rb.GetBackgroundColour()
        print "combobox defaults: points='%d', \
family='%s', style='%s', weight='%s',
backgcolour='%s', encoding='%s'" % \
                (points, family, style, weight, bgc,
encoding)
        newfont = wx.Font(points+2, family, style,
weight, encoding=encoding)

        #**** THIS STATEMENT CAUSES THE PROBLEM ***
        self.rb.SetFont(newfont)

        rbsizer = wx.BoxSizer(wx.HORIZONTAL)
        rbsizer.Add(self.rb, 1, wx.ALIGN_LEFT|wx.ALL,
0)

        self.SetSizer(rbsizer)
        self.Show(True)

    def EvtTextEnter (self, event) :
        value = self.rb.GetValue()
        self.rb.Clear()
        for item in self.itemlist :
            self.rb.Append(item, "")
        self.rb.Append(value, "")

class MainWindow(wx.Frame):
    def __init__(self,parent,id, title):
       
wx.Frame.__init__(self,parent,wx.ID_ANY,title,size=(400,200),
                         
style=wx.DEFAULT_FRAME_STYLE)

        self.control = DisplayComboBoxPanel(self,-1)
        self.Show(True)

app = wx.PySimpleApp()

frame=MainWindow(None,-1, 'test window')
frame.Show()
app.MainLoop()

Originally I didn't have the encoding parameter
specified in the call to wx.Font.
The code above is modified to read the current
encoding and specify the same for wx.Font. But that
doesn't solve the problem either. Not sure why only
Korean is affected as Russian, Chinese, and other
foreign characters will be displayed just fine.

Is there any way to change the font size of the list
without messing up the display for Korean characters?

Thanks,

Jeremy.

--- Robin Dunn <robin@alldunn.com> wrote:

jeremy alexander wrote:

> I tried to reproduce in the wxpython demo by
modifying
> the combobox demo so that it uses the same
technique
> as the app to insert characters from the text area
> into the list. But this worked just fine!

Then there must be something different about your
app. Try to narrow
down the differences between it an the demo and you
may find the source
of the problem.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax
with wxPython!

In my app, If I paste Korean characters into the

text

area of a combo box, press enter, and the combo box
uses the textenter event to read the pasted text and
insert it into the list box area, then the following
happens:
1)
the korean characters display fine in the text area
2)
after copying them to the list box area and pulling
down the menu, the characters appear as little
squares.

This does not happen if I paste bulgarian, chinese,
russian, or other characters available in the

wxpython

demo.

If I paste Korean characters into a listctrl or a
textctrl of the app, they display with no problems.

Why would the korean characters display properly
everywhere except within a listbox?

I tried to reproduce in the wxpython demo by

modifying

the combobox demo so that it uses the same technique
as the app to insert characters from the text area
into the list. But this worked just fine!

When I display the locale and default codec in the
demo and in my application, they both show:

Locale is: ('en_CA', 'cp1252'), Default Codec is:
'cp1252'

I'm using Windows XP SP2, wxpython 2.6.3.3 (unicode
version) and python 2.4.4
The demo is for 2.6.3.3

If anyone has any ideas on what could be happening

and

how to fix it, i'd really appreciate it.

Thanks,

Jeremy.

____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
http://farechase.yahoo.com/