[PyQt] wchar_t type mapping

Phil Thompson phil at riverbankcomputing.com
Thu Jun 25 12:54:23 BST 2009


On Sun, 21 Jun 2009 17:04:16 +0200, "Diez B. Roggisch" <deets at web.de>
wrote:
> Diez B. Roggisch schrieb:
>> Hi,
>> 
>> I want to wrap a method with the following signature:
>> 
>> virtual irr::gui::IGUIStaticText* addStaticText(const wchar_t* text, 
>> const irr::core::rect<irr::s32>& rectangle,
>>                               bool border=false, bool wordWrap=true, 
>> irr::gui::IGUIElement* parent=0, irr::s32 id=-1,
>>                               bool fillBackground = false) = 0;
>> 
>> 
>> All types are mapped or declared, and compilation succeeds.
>> 
>> However, on calling the function, Python barks with
>> 
>> 
>> 
>> Traceback (most recent call last):
>>   File "hello_world.py", line 64, in <module>
>>     main()
>>   File "hello_world.py", line 45, in main
>>     True);
>> TypeError: argument 1 of IGUIEnvironment.addStaticText() has an invalid 
>> type
> 
> Ok, I found the problem - one needs to pass a unicode-object. While this 
> makes sense to a certain degree, I think it would be good to enhance the 
> mapping of wchar_t so that an attempt to convert bytestrings to unicode 
> is done (as it is in other python APIs), potentially producing a 
> UnicodeDecodeError of course. Would that be something worth considering?

Seems reasonable. The next SIP release is likely to be v4.9, but snapshots
won't start appearing for a while.

Phil


More information about the PyQt mailing list