Advertisement
MyNamesNotReallyDave

PyQT5 - Signals & Slots Tutorial

Nov 11th, 2019
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. from PyQt5.QtWidgets import *
  2. from PyQt5.QtGui import *
  3. from PyQt5.QtCore import *
  4.  
  5. import sys
  6.  
  7. class Window(QMainWindow):
  8.     def __init__(self):
  9.         super().__init__()
  10.  
  11.         self.title = 'PyQt5 - Events, Signals & Slots'
  12.         self.top = 100
  13.         self.left = 100
  14.         self.width = 400
  15.         self.height = 300
  16.  
  17.         self.InitWindow()
  18.  
  19.     def InitWindow(self):
  20.         self.setWindowIcon(QIcon('skull_icon.png'))
  21.         self.setWindowTitle(self.title)
  22.         self.setGeometry(self.left, self.top, self.width, self.height)
  23.  
  24.         self.CreateButton()
  25.         self.show()
  26.  
  27.     def CreateButton(self):
  28.         self.button = QPushButton('Close', self).setGeometry(QRect(100, 100, 111, 50))
  29.         self.button.clicked.connect(self.ClickMe())
  30.  
  31.     def ClickMe(self):
  32.         sys.exit()
  33.  
  34.  
  35. if __name__ == '__main__':
  36.     App = QApplication(sys.argv)
  37.     window = Window()
  38.     sys.exit(App.exec())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement