這是一個學校專案(筆記本),我正在開始,我是一個新手,下面的代碼是我仍在努力解決的問題......因為我正在構建一個 GUI。
import sys
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtGui import QIcon
class App(QWidget):
def __init__(self):
super().__init__()
self.title='Hello, world!'
self.left=10
self.top=10
self.width=-640
self.height =400
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left,self.top,self.width,self.height)
show()
if __name__=='__main__':
app=QApplication(sys.argv)
ex=App()
app.exit(sys)
uj5u.com熱心網友回復:
試試我的修復
我添加self.initUI()了啟動您的功能,該功能提供標題名稱并顯示您的QWidget應用程式
我用你的最后一行替換了 sys.exit(app.exec_())
-- 完整的修復代碼 --
import sys
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtGui import QIcon
class App(QWidget):
def __init__(self):
super().__init__()
self.title='Hello, world!'
self.left=10
self.top=10
self.width=640
self.height=480
self.initUI()
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left,self.top,self.width,self.height)
self.show()
if __name__=='__main__':
app=QApplication(sys.argv)
ex=App()
sys.exit(app.exec_())
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/408673.html
標籤:
上一篇:Python-將用戶分配給子OU
