| 123456789101112131415161718192021222324252627282930 |
- import sys
- from PyQt5.QtWidgets import QMainWindow, QPushButton, QApplication
- class MainWindow(QMainWindow):
- def __init__(self):
- super().__init__()
- self.setWindowTitle("My App")
- self.button = QPushButton("Press Me!")
- self.button.clicked.connect(self.the_button_was_clicked)
- # Set the central widget of the window
- self.setCentralWidget(self.button)
- def the_button_was_clicked(self):
- self.button.setText("You already clicked me.")
- self.button.setEnabled(False)
- self.setWindowTitle("A new window title")
- app = QApplication(sys.argv)
- window = MainWindow()
- window.show()
- app.exec_()
|