[PyQt] SIP example code issue with python 3.3
Phil Thompson
phil at riverbankcomputing.com
Wed Apr 30 16:31:56 BST 2014
On 30/04/2014 4:09 pm, Christoff Kok wrote:
> Hi,
>
> I apologize if I am using the mailing system wrong, please correct me
> if I do. 1st time user of such a channel.
>
> I trying to learn SIP and came across an issue when trying to
> implement the example code given in the documentation.
> /////////////////////////////////
> %Module word
>
> %TypeHeaderCode
> #include "word.h"
> #include <string.h>
> %End
>
> public:
> Word(const char *w);
> char *reverse() const;
> };
> /////////////////////////////////
>
> After successfully running the deploying it in python, I tried to
> create a Word variable: e.g.
>
>>>> from word import Word
>>>> w = Word("cheese snacks")
> # PYTHON THROWS AN ERROR HERE:
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: Word(): arguments did not match any overloaded call:
> overload 1: too many arguments
> overload 2: argument 1 has unexpected type 'str'
> # HELP(WORD) INFORMS ME THAT WORD IS EXPECTING A SIP.WRAPPER OBJECT,
> NOT A STRING AS I EXPECTED
No. What it's saying is that the super-class of Word is sip.wrapper.
>>>> help(Word)
> Help on class Word in module word:
>
> class Word(sip.wrapper)
> ...
>
> This was not expected, I expected it to just work as the example
> given. Any help? I am working on Windows 7 in python 3.3.4
> I tried including MappedType char * but received the error: "Invalid
> type for %MappedType"
You need to consider the encoding, see...
http://pyqt.sourceforge.net/Docs/sip4/annotations.html#argument-annotation-Encoding
Phil
More information about the PyQt
mailing list