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

List:       pykde
Subject:    [PyKDE] BUG - disconnect
From:       Kaleb Pederson <kibab () icehouse ! net>
Date:       2002-10-29 0:46:11
[Download RAW message or body]

Disconnect doesn't seem to work as expected.

Per the Qt documentation (qobject.html#disconnect) I should be able to 
disconnect signals as follows.

I've tried various methods:

    def sigDiscon(self):
        self.disconnect() # Test 1
        #QObject.disconnect(self,0,0,0) # Test 2 - or None,None,None
        #self.disconnect(PYSIGNAL("fireAway")) # Test 3
        #self.disconnect(SIGNAL("clicked()")) # Test 4
        #QObject.disconnect(self,SIGNAL("clicked()")) # Test 5
        #QObject.disconnect(self,SIGNAL("clicked()"),0) # Test 6 - or None
        #QObject.disconnect(self,PYSIGNAL("fireAway")) # Test 7

which are all very similar to the documentation examples.  SIP can't seem to 
tell which method really should be called, and None and 0 aren't accepted as 
valid wild cards so I can't really give it the parameters that I need.

I've attached an example that demonstrates the above.

--Kaleb
["distest.py" (text/x-python)]

#!/usr/bin/python

from qt import *
import sys

class MyDialog(QDialog):
	
	def __init__(self,parent = None,name = "MyDialog",modal=0,fl=0):
		QDialog.__init__(self,parent,name,modal,fl)

		self.setCaption("Testing")

		main_layout = QVBoxLayout(self,11,6,"main_layout")
		
		self.button1 = QPushButton(self,"button1")
		self.button1.setText(u'fire')
		
		main_layout.addWidget(self.button1)
		self.connect(self.button1,SIGNAL("clicked()"),self.fire)
		self.connect(self.button1,SIGNAL("clicked()"),self.fireAway)

		self.button2 = QPushButton(self,"button2")
		self.button2.setText(u'disconnect')
		
		main_layout.addWidget(self.button2)
		self.connect(self.button2,SIGNAL("clicked()"),self.sigDiscon)

		self.button3 = QPushButton(self,"button3")
		self.button3.setText(u'Quit')

		main_layout.addWidget(self.button3)
		self.connect(self.button3,SIGNAL("clicked()"),SLOT("accept()"))
		
	def sigDiscon(self):
		self.disconnect() # Test 1 
		#QObject.disconnect(self,0,0,0) # Test 2 - or None,None,None
		#self.disconnect(PYSIGNAL("fireAway")) # Test 3
		#self.disconnect(SIGNAL("clicked()")) # Test 4
		#QObject.disconnect(self,SIGNAL("clicked()")) # Test 5
		#QObject.disconnect(self,SIGNAL("clicked()"),0) # Test 6 - or None
		#QObject.disconnect(self,PYSIGNAL("fireAway")) # Test 7


	def fireAway(self):
		self.fire("fireAway")

	def fire(self,msg = u"Message"):
		mb = QMessageBox(self,"mb")
		mb.setCaption(u"Caption")
		mb.setText(msg)
		mb.exec_loop()
	

qapp = QApplication(sys.argv)
mw = MyDialog()
qapp.setMainWidget(mw)
mw.show()
sys.exit(mw.exec_loop())

_______________________________________________
PyKDE mailing list    PyKDE@mats.gmd.de
http://mats.gmd.de/mailman/listinfo/pykde

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

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