wx.ListCtrl.SetStringItem() and UnicodeDecodeError

Hi,

I don't know the first thing about encodings so I'm completely lost on this
one. I'm trying to create an email viewer. I am populating a wx.ListCtrl
using SetStringItem(). I've found the subject line of certain emails will
continain characters of different encondings (I'm guessing) and that's when I
get the exception below. Where do I look for the solution for this? Is there
an easy fix? Or does this turn into a bit of a hairball? Any ideas or
suggestions?

Thanks,
Tom

Traceback (most recent call last):
  File "./kmailreader.py", line 179, in onTreeSelChanged
    self.fillList(self.list, data)
  File "./kmailreader.py", line 170, in fillList
    self.list.SetStringItem(index, 1, msg['From'])
  File "/usr/local/lib/python2.3/site-packages/wx/_controls.py", line 4300, in
SetStringItem
    return _controls_.ListCtrl_SetStringItem(*args, **kwargs)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 3:
ordinal not in range(128)

Hi
I have 2 wxGauge in one frame and no static text will display. If I
comment out one gauge it works fine.
Any help much appreciated.
Greg

Can you give us a code snippet?

···

On Mon, 2004-09-20 at 08:50 +1000, Greg Binns wrote:

Hi
I have 2 wxGauge in one frame and no static text will display. If I
comment out one gauge it works fine.
Any help much appreciated.

--
Cliff Wells <clifford.wells@comcast.net>

1 Like

Hi
Further investigation seems to reveal that other processes start before
the static text has time to draw.
New question, how do I force them to draw immediately
Thanks

···

-----Original Message-----
From: Cliff Wells [mailto:clifford.wells@comcast.net]
Sent: Monday, 20 September 2004 10:11 AM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] wxGauge

On Mon, 2004-09-20 at 08:50 +1000, Greg Binns wrote:

Hi
I have 2 wxGauge in one frame and no static text will display. If I
comment out one gauge it works fine.
Any help much appreciated.

Can you give us a code snippet?

--
Cliff Wells <clifford.wells@comcast.net>

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

1 Like

You can use the Refresh() and/or Update() methods of the items
immediately after the window is created.

Cliff

···

On Mon, 2004-09-20 at 11:55 +1000, Greg Binns wrote:

Hi
Further investigation seems to reveal that other processes start before
the static text has time to draw.
New question, how do I force them to draw immediately

--
Cliff Wells <clifford.wells@comcast.net>

1 Like

Tom Brown wrote:

Hi,

I don't know the first thing about encodings so I'm completely lost on this one. I'm trying to create an email viewer. I am populating a wx.ListCtrl using SetStringItem(). I've found the subject line of certain emails will continain characters of different encondings (I'm guessing) and that's when I get the exception below. Where do I look for the solution for this? Is there an easy fix? Or does this turn into a bit of a hairball? Any ideas or suggestions?

Find out what encoding the string is encoded with (it's in the message headers isn't it?) and then use st.decode(encoding) to get a unicode version of it.

···

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

1 Like