PyQt Signals and multiple sources

John Posner jjposner at optimum.net
Sun Dec 20 17:15:30 EST 2009


On Sun, 20 Dec 2009 16:59:11 -0500, Zabin <zabin.farishta 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



More information about the Python-list mailing list