pyqt5 create own signal code example
Example 1: pyqt5 create own signal
for i in range(10):
bag.punch()
Example 2: pyqt5 create own signal
@pyqtSlot()
def say_punched():
''' Give evidence that a bag was punched. '''
print('Bag was punched.')
bag = PunchingBag()
bag.punched.connect(say_punched)
Example 3: pyqt5 create own signal
from PyQt4.QtCore import QObject, pyqtSignal, pyqtSlot
class PunchingBag(QObject):
''' Represents a punching bag; when you punch it, it
emits a signal that indicates that it was punched. '''
punched = pyqtSignal()
def __init__(self):
QObject.__init__(self)
def punch(self):
''' Punch the bag '''
self.punched.emit()