[PyQt] SIP example code issue with python 3.3

Christoff Kok christoff.kok at ex-mente.co.za
Mon May 5 13:11:02 BST 2014


Thank you Phill.

This fixed my issue.

Thanks a lot for the help.


On 30 April 2014 17:31, Phil Thompson <phil at riverbankcomputing.com> wrote:

> 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
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt




-- 
Christoff Kok
Software Engineer
Ex Mente

http://www.ex-mente.co.za
christoff.kok at ex-mente.co.za
PO Box 10214
Centurion
0046
South Africa
tel: +27 12 743 6993
tel: +27 12 654 8198
fax: +27 85 150 1341
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140505/37838a2f/attachment.html>


More information about the PyQt mailing list