[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyQt] Bug obtaining signal's sender with decorated slots (was:
From: Albert Cervera i Areny <albert () nan-tic ! com>
Date: 2010-06-24 22:24:59
Message-ID: 201006250024.59783.albert () nan-tic ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
A Diumenge, 20 de juny de 2010, Albert Cervera i Areny va escriure:
> We're changing an application from using old-style 'connect(SIGNAL()
> SLOT())' functions to new-style 'signal.connect( slot )' ones but it
> seems that executing 'self.sender()' in the slot doesn't have the same
> behaviour as it used to because it always returns None.
>
> Is there a way to know who called the slot with new-style signal and slot?
The attached file demonstrates the problem. sender() function doesn't work if
signal is emited using the new-style signal.emit() and the slot is decorated
using @pyqtSlot()
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
> _______________________________________________
> PyQt mailing list PyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
--
Albert Cervera i Areny
http://www.NaN-tic.com
OpenERP Partner
Mòbil: +34 669 40 40 18
[Attachment #5 (text/html)]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" \
"http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" \
content="1" /><style type="text/css"> p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'Sans Serif'; font-size:12pt; \
font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">A Diumenge, 20 de juny de 2010, Albert Cervera i Areny va \
escriure:</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">> We're \
changing an application from using old-style 'connect(SIGNAL()</p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">> SLOT())' functions to \
new-style 'signal.connect( slot )' ones but it</p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">> seems that executing 'self.sender()' in the \
slot doesn't have the same</p> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">> behaviour as it used to because it always returns None.</p> \
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">> </p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">> Is there a way to know \
who called the slot with new-style signal and slot?</p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"></p> <p \
style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">The attached file \
demonstrates the problem. sender() function doesn't work if signal is emited using \
the new-style signal.emit() and the slot is decorated using @pyqtSlot()</p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"></p> <p \
style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">> </p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">> \
----------------------------------------------------------------</p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">> This message was sent \
using IMP, the Internet Messaging Program.</p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">> </p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">> </p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">> \
_______________________________________________</p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">> PyQt mailing list \
PyQt@riverbankcomputing.com</p> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">> http://www.riverbankcomputing.com/mailman/listinfo/pyqt</p> \
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"></p> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"><br />-- </p> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">Albert Cervera i Areny</p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;"><a href="http://www.NaN-tic.com"><span style=" \
text-decoration: underline; color:#0057ae;">http://www.NaN-tic.com</span></a></p> <p \
style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><a \
href="http://www.NaN-tic.com"><span style=" text-decoration: underline; \
color:#0057ae;">OpenERP Partner</span></a></p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">Mòbil: +34 669 40 40 18</p></body></html>
["test.py" (text/x-python)]
from PyQt4.QtCore import *
class A(QObject):
signal1 = pyqtSignal()
signal2 = pyqtSignal()
def __init__(self):
QObject.__init__(self)
self.signal1.connect( self.slot1 )
self.signal1.emit()
self.signal2.connect( self.slot2 )
self.signal2.emit()
@pyqtSlot()
def slot1(self):
print "SLOT1: ", self.sender()
def slot2(self):
print "SLOT2: ", self.sender()
o = A()
_______________________________________________
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