1.创建Qt项目
2.Pyuic到处Qt为python代码
# - * - coding: utf- 8 - * -
# Form implementation generated from reading ui file 'first.ui'
#
# Created by: PyQt5 UI code generator 5.9 .2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form ( object) :
def setupUi ( self, Form) :
Form. setObjectName ( "Form" )
Form. resize ( 400 , 300 )
self. listView = QtWidgets. QListView ( Form)
self. listView. setGeometry ( QtCore. QRect ( 10 , 10 , 371 , 251 ) )
self. listView. setObjectName ( "listView" )
self. retranslateUi ( Form)
QtCore. QMetaObject. connectSlotsByName ( Form)
def retranslateUi ( self, Form) :
_translate = QtCore. QCoreApplication. translate
Form. setWindowTitle ( _translate ( "Form" , "Form" ) )
3.创建主函数
import sys
import first
from PyQt5. QtWidgets import QApplication, QMainWindow
if __name__== "__main__" :
app= QApplication ( sys. argv)
mainWindow= QMainWindow ( )
ui= first. Ui_Form ( )
ui. setupUi ( mainWindow)
mainWindow. show ( )
sys. exit ( app. exec_ ( ) )
5.运行结果