需先安裝 Eric
2.設定 Eric 3.Eric 開啟專案 4.新增一個 python 檔案 將 Untitled 1 另存新檔,檔名為 test.py (可自訂) 5.鍵入程式碼並選擇功能表 Start ==> Run Script...
import sys from PyQt5.QtWidgets
import QPushButton, QApplication, QWidget class aWinForm(QWidget): def __init__(self, parent = None): super(aWinForm, self).__init__(parent) self.setGeometry(300, 300, 350, 350) self.setWindowTitle("Close Window") quit = QPushButton("close", self) quit.setGeometry(10, 10, 60, 35) quit.setStyleSheet("background-color:yellow") quit.clicked.connect(self.close) if __name__ == "__main__": app = QApplication(sys.argv) win = aWinForm() win.show() sys.exit(app.exec_()) 6.執行結果 |