[PyQt] wchar_t type mapping

Diez B. Roggisch deets at web.de
Sun Jun 21 16:04:16 BST 2009

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?


More information about the PyQt mailing list