PyQt Signals and multiple sources

Zabin zabin.farishta at gmail.com
Sun Dec 20 17:33:39 EST 2009


On Dec 21, 11:15 am, "John Posner" <jjpos... at optimum.net> wrote:
> On Sun, 20 Dec 2009 16:59:11 -0500, Zabin <zabin.faris... at gmail.com> wrote:
> > I am beginner in programming in pyqt. I have been trying to call the
> > same function from multiple events- but each event results in a
> > different instance of the function. I am just unable to figure out how
> > to retrieve the source which calls the function:
>
> > My source signal declarations are as below:
> > QtCore.QObject.connect(self.ui.Button_Process, QtCore.SIGNAL("clicked
> > ()"), self.activate_tab)
> > QtCore.QObject.connect(self.ui.Button_Material, QtCore.SIGNAL("clicked
> > ()"), self.activate_tab)
> > QtCore.QObject.connect(self.ui.Button_Geometry, QtCore.SIGNAL("clicked
> > ()"), self.activate_tab)
>
> > for each of the above source i want to activate a different instance
> > of the activate_tab function. Any help would be greatly appreciated!
>
> In the self.activate_tab() method, use self.sender() to determine which  
> object sent the signal.
>
> -John- Hide quoted text -
>
> - Show quoted text -

Awesum. That works!

To get the object name you just need to use self.sender().objectName()

Cheers!



More information about the Python-list mailing list