Created
August 26, 2015 18:47
-
-
Save saleph/a5e840e3b73a117107ad to your computer and use it in GitHub Desktop.
[qt5] signal & slots - custom emiter (mouse click)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'tom' | |
import sys | |
from PyQt5.QtCore import pyqtSignal, QObject | |
from PyQt5.QtWidgets import QMainWindow, QApplication | |
class Communicate(QObject): | |
close_app = pyqtSignal() | |
class Example(QMainWindow): | |
def __init__(self): | |
super().__init__() | |
self.init_ui() | |
def init_ui(self): | |
self.c = Communicate() | |
self.c.close_app.connect(self.close) | |
self.setGeometry(300, 300, 290, 150) | |
self.setWindowTitle('Emit signal') | |
self.show() | |
def mousePressEvent(self, QMouseEvent): | |
self.c.close_app.emit() | |
if __name__ == "__main__": | |
app = QApplication(sys.argv) | |
ex = Example() | |
sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment