[PyKDE] Problem resolving widget's class

David Boddie david at boddie.org.uk
Tue Nov 2 15:07:56 GMT 2004


[Sorry if this appears twice: webmail and character encoding issues...] 
 
On Tue, 2 Nov 2004 13:22:28, Fredrik Juhlin wrote: 
 
>On Monday 01 November 2004 19.30, David Boddie wrote: 
>> 
>> This sounds a lot like the problems you can experience when embedding 
>> Python in C++ applications through a dlopened plugin mechanism. 
>> Can you successfully "cast" the widget pointers to the appropriate 
>> types by using sip.unwrapinstance and sip.wrapinstance functions? 
 
>First: We're not embedding Python in a C++ app. It's a pure Python  
>application. 
 
OK. When people talk about getting objects from C++ land, I tend to 
assume that they're embedding Python. 
 
>Not knowing a whole lot about SIP, I looked through the SIP docs and added 
>the following lines of code at a known trouble spot (setting the text of 
>QLabels in forms), which I believe is what you meant I should try (if I got 
>it wrong, let me know :): 
>if not isinstance(labelWidget, qt.QLabel): 
>    import sip 
>    apa = sip.unwrapinstance(labelWidget) 
>    foo = sip.wrapinstance(apa, qt.QLabel) 
>    labelWidget = foo 
 
That's what I meant. It's really only meant for peculiar situations 
involving embedded interpreters, so you shouldn't need it here because 
SIP will do the right thing. 
 
I ran the test program that you posted in another message 
(http://mats.imk.fraunhofer.de/pipermail/pykde/2004-November/008977.html) 
and found that it always crashed the second time I clicked the update 
button. 
 
I changed oldForm.close(1) in line 33 of test.py to oldForm.close() and 
experienced no crashes for the admittedly short time that I ran it again. 
I think that the problem may be that you're instructing Qt to delete the 
objects on the C++ side, and SIP isn't too happy about this later on. 
 
Hope this helps, 
 
David 


___________________________________________________________
$0 Web Hosting with up to 120MB web space, 1000 MB Transfer
10 Personalized POP and Web E-mail Accounts, and much more.
Signup at www.doteasy.com




More information about the PyQt mailing list