creating_a_window_4.py 484 B

123456789101112131415161718192021222324
  1. import sys
  2. from PyQt5.QtCore import QSize
  3. from PyQt5.QtWidgets import QMainWindow, QPushButton, QApplication
  4. class MainWindow(QMainWindow):
  5. def __init__(self):
  6. super().__init__()
  7. self.setWindowTitle("My App")
  8. button = QPushButton("Press Me!")
  9. self.setFixedSize(QSize(400, 300))
  10. # Set the central widget of the window
  11. self.setCentralWidget(button)
  12. app = QApplication(sys.argv)
  13. window = MainWindow()
  14. window.show()
  15. app.exec_()