Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python calling two functions by clicking one button in PyQt

Tags:

python

qt

pyqt

I am new to Python. I have created a button using PyQt and want to call two separate functions by clicking the same button

QtCore.QObject.connect(self.start, QtCore.SIGNAL('clicked()'), self.trial,self.trial2)
like image 782
user2693313 Avatar asked Aug 29 '15 11:08

user2693313


1 Answers

You can just connect the signal twice, like:

QtCore.QObject.connect(self.start, QtCore.SIGNAL('clicked()'), self.trial)
QtCore.QObject.connect(self.start, QtCore.SIGNAL('clicked()'), self.trial2)

Both functions will be called when the signal is emitted. According to the document:

If a signal is connected to several slots, the slots are activated in the same order in which the connections were made, when the signal is emitted.

like image 164
Thomas Lee Avatar answered Sep 29 '22 08:09

Thomas Lee