| 123456789101112131415161718192021222324252627 |
- import sys
- from PyQt5.QtWidgets import QMainWindow, QPushButton, QApplication
- def the_button_was_clicked():
- print("Button was clicked")
- class MainWindow(QMainWindow):
- def __init__(self):
- super().__init__()
- self.setWindowTitle("My App")
- button = QPushButton("Press Me!")
- button.clicked.connect(the_button_was_clicked)
- # Set the central widget of the window
- self.setCentralWidget(button)
- app = QApplication(sys.argv)
- window = MainWindow()
- window.show()
- app.exec_()
|