467,906 Members | 1,604 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,906 developers. It's quick & easy.

passing tuple with pyqt4 signal/slot mechanism

Hello,
I have a pyqt4 code in which i'm trying the signal/slot mechanism. The
(stripped) code is as follows:

class D(QtCore.QThread):
def __init__(self):
QtCore.QThread.__init__(self)
tpl = ("Primary", "priSec")
print "tpl:", tpl
self.emit(QtCore.SIGNAL("setLabel"), tpl)
class Gui(QtGui.QDialog):
def __init__(self, parent = None):
QtGui.QDialog.__init__(self, parent)
def setLabel(self, tpl):
print "####tpl:", tpl
print "**********tpl:", str(tpl)
return
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
dialog = Gui()
d = D()
QtCore.QObject.connect(d, QtCore.SIGNAL("setLabel"),
dialog.setLabel, QtCore.Qt.QueuedConnection)
sys.exit(dialog.exec_())

The output i'm getting is as follows:

tpl: ('Primary', 'priSec')
####tpl: (<refcnt 0 at 0xb7caac8c>,)
**********tpl: ((((((((<NULL>,),),),),),),),)

Can anyone kindly tell me what's happening here? Why is the tuple
("Primary", "priSec") getting converted to this <NULLthingy? And
what is this thingy anyways (It looks to be a deeply nested tuple, but
am not sure).

Thanks a lot!
--
warm regards,
Pradnyesh Sawant
--
Be yourself, everyone else is taken. --Anon
Apr 26 '07 #1
  • viewed: 2031
Share:
2 Replies
Pradnyesh Sawant schrieb:
Hello,
I have a pyqt4 code in which i'm trying the signal/slot mechanism. The
(stripped) code is as follows:

class D(QtCore.QThread):
def __init__(self):
QtCore.QThread.__init__(self)
tpl = ("Primary", "priSec")
print "tpl:", tpl
self.emit(QtCore.SIGNAL("setLabel"), tpl)
class Gui(QtGui.QDialog):
def __init__(self, parent = None):
QtGui.QDialog.__init__(self, parent)
def setLabel(self, tpl):
print "####tpl:", tpl
print "**********tpl:", str(tpl)
return
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
dialog = Gui()
d = D()
QtCore.QObject.connect(d, QtCore.SIGNAL("setLabel"),
dialog.setLabel, QtCore.Qt.QueuedConnection)
sys.exit(dialog.exec_())

The output i'm getting is as follows:

tpl: ('Primary', 'priSec')
####tpl: (<refcnt 0 at 0xb7caac8c>,)
**********tpl: ((((((((<NULL>,),),),),),),),)

Can anyone kindly tell me what's happening here? Why is the tuple
("Primary", "priSec") getting converted to this <NULLthingy? And
what is this thingy anyways (It looks to be a deeply nested tuple, but
am not sure).
It's just wild guessing back from my Qt3-days - but isn't PYSIGNAL
instead of SIGNAL necessary here?

Diez
Apr 26 '07 #2
On Thursday 26 April 2007 3:41 pm, Diez B. Roggisch wrote:
Pradnyesh Sawant schrieb:
Hello,
I have a pyqt4 code in which i'm trying the signal/slot mechanism. The
(stripped) code is as follows:

class D(QtCore.QThread):
def __init__(self):
QtCore.QThread.__init__(self)
tpl = ("Primary", "priSec")
print "tpl:", tpl
self.emit(QtCore.SIGNAL("setLabel"), tpl)
class Gui(QtGui.QDialog):
def __init__(self, parent = None):
QtGui.QDialog.__init__(self, parent)
def setLabel(self, tpl):
print "####tpl:", tpl
print "**********tpl:", str(tpl)
return
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
dialog = Gui()
d = D()
QtCore.QObject.connect(d, QtCore.SIGNAL("setLabel"),
dialog.setLabel, QtCore.Qt.QueuedConnection)
sys.exit(dialog.exec_())

The output i'm getting is as follows:

tpl: ('Primary', 'priSec')
####tpl: (<refcnt 0 at 0xb7caac8c>,)
**********tpl: ((((((((<NULL>,),),),),),),),)

Can anyone kindly tell me what's happening here? Why is the tuple
("Primary", "priSec") getting converted to this <NULLthingy? And
what is this thingy anyways (It looks to be a deeply nested tuple, but
am not sure).

It's just wild guessing back from my Qt3-days - but isn't PYSIGNAL
instead of SIGNAL necessary here?
No, PyQt4 used SIGNAL for both Qt and Python signals.

Phil
Apr 26 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Glen | last post: by
reply views Thread by Pradnyesh Sawant | last post: by
2 posts views Thread by jiang.haiyun | last post: by
9 posts views Thread by bullockbefriending bard | last post: by
reply views Thread by kunalgalav | last post: by
2 posts views Thread by Bighead | last post: by
3 posts views Thread by ff | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.