[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] SIP example code issue with python 3.3
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2014-04-30 15:31:56
Message-ID: 33c0126c3c1a23f0e55833dd5cec9e3b () www ! riverbankcomputing ! com
[Download RAW message or body]

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@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic