pyqt5--gui hello world

step 1:使用qt designer建立.ui文件(helloworld.ui)python

step 2:建立一個獨立的main.py文件,並加載helloworld.uiapp

import sys
from PyQt5 import  QtWidgets
from PyQt5.uic import loadUi
class mywin(QtWidgets.QDialog):
    def __init__(self):
        super(mywin,self).__init__()
        loadUi('helloworld.ui',self)

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    w = mywin()
    w.show()
    w.setWindowTitle("window")
    sys.exit(app.exec_())

step3 運行main.pyui

相關文章
相關標籤/搜索