本文最后更新于 2024-08-07T17:07:25+08:00
PyQt
添加图标
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| class WindowGUI(QMainWindow, Ui_MainWindow): def __init__(self): super(WindowGUI, self).__init__() self.setupUi(self) self.setWindowIcon(QIcon('./Data/SerialBlack.ico')) self.pushButton.clicked.connect(self.Butt)
if __name__ == '__main__': app = QApplication(sys.argv) window = WindowGUI() window.show() sys.exit(app.exec_())
|
退出确认
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| class WindowGUI(QMainWindow, Ui_MainWindow): def __init__(self): super(WindowGUI, self).__init__() self.setupUi(self) def closeEvent(self, event): reply = QMessageBox.question(self, 'Message', "Are you sure to quit?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if reply == QMessageBox.Yes: event.accept() else: event.ignore()
if __name__ == '__main__': app = QApplication(sys.argv) window = WindowGUI() window.show() sys.exit(app.exec_())
|
PyQT
https://www.oikiou.top/2020/7ecf7a99/