This is an API inconsistency (or an undocumented limitation).
Yes, it is.
DC.DrawText does accept unicode strings, including non-Ascii
characters,but DC.DrawTextList does not. It fails with the
following error:Traceback (most recent call last):
[...]
File "/usr/lib/python2.4/site-packages/wx-2.5.3-gtk2-
ansi/wx/_gdi.py", line 3811, in DrawTextList
return self._DrawTextList(textList, coords, foregrounds,
backgrounds) File "/usr/lib/python2.4/site-packages/wx-2.5.3-gtk2-
ansi/wx/_gdi.py", line 3653, in _DrawTextList
return _gdi_.DC__DrawTextList(*args, **kwargs)
TypeError: Expected a sequence of strings
I wrote that code a while ago, when unicode was not as common. In
addition, I never use unicide myself. If you would like to fix this,
take a look at the source, I think you'll need to look in gdi.i and or
gdi.cpp and/or gdi.h This is from memory, as I don't have the source on
this machine. I also dont' remember when that type check happens, but
it's probabably a very simple check for a Python String, that could be
changed to a check for a string or unicode object. Take a look at the
Python C API to see how to do this. ONe more note: DrawSextList should
really be using the same code as the rest of wxPython to convert from a
Python string to a wxString, and that works OK for Unicode, so maybe
some restructuring is in order. That would probably be tricky for anyone
not familiar with the wxPython wrappers, but it could be educational to try!
Maybe I'll work on thnis some day, but don't bet on it.
By the way, even though I added many of the DrawXXXList methods, IO've
bee disappointed by the performance of most other than DrawPointList. I
don't remember how much DrawTexstList really helped. You may be just as
well off writting your loop in Python and being done with it.
-Chris
-Chris
···
----- Original Message -----
From: Antoine Pitrou <solipsis@pitrou.net>