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

List:       pykde
Subject:    RE: [PyKDE] Static member functions
From:       "Phil Thompson" <phil () riverbankcomputing ! co ! uk>
Date:       2004-12-15 9:15:32
Message-ID: 2263.82.68.80.137.1103102132.squirrel () 82 ! 68 ! 80 ! 137
[Download RAW message or body]

>
> Followup: I seem to have found sender(), but I get the usual 'you can't
> do this because it was not created in python' error.
>
> So I still don't know how to go about it. Here's a sample class that I
> just typed up:
>
> class testDlg:
> 	def __init__(self):
> 		self.dlg=QWidgetFactory.create('lineedit.ui') #just a
> dialog with 2 lineedit boxes named lineedit1 and lineedit2, clicking
> between them should print out different instances
> 		self.dlg.connect(self.dlg.child('lineedit1'),
> SIGNAL('lostFocus()'), self.lostFocus)
>
> 	def lostFocus(self):
> 		print self.dlg.sender() # error here
>
> 	def show(self):
> 		self.dlg.show()
> if __name__=='__main__':
> 	d=testDlg()
> 	d.show()
> 	qApp.exec_loop()

Like I said, the slot must be a member of a QObject derived class. Also,
sender() should be from the receiver - there's no point in asking the
sender who the sender is :)

So, testDlg should sub-class from QObject and the lostFocus() method
should be...

    def lostFocus(self):
        print self.sender()

Phil

_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.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