PyQt Signals and multiple sources

Z

Zabin

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!
 
J

John Posner

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
 
Z

Zabin

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top