用pyqt进行python可视化编程

在pyqt中创建Qt 设计形式
https://blog.csdn.net/Alvwith/article/details/124163574
选择widget,然后设计界面转为py文件。
就会得到一个设计好的窗体类。

 

 
 
 
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'E:\DingDing\form.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(400, 300)
        self.pushButton = QtWidgets.QPushButton(Form)
        self.pushButton.setGeometry(QtCore.QRect(180, 180, 93, 28))
        self.pushButton.setObjectName("pushButton")

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.pushButton.setText(_translate("Form", "好好"))

import sys
from PyQt5 import QtWidgets
if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    basewidget = QtWidgets.QWidget() #创建窗体的基类Qwidget的实例对象basewidget
    ui = Ui_Form()
    ui.setupUi(basewidget)  #传入窗体对象basewidget,创建完整窗体
    basewidget.show() #显示窗体
    sys.exit(app.exec_())


posted @ 2023-05-05 14:15  祥瑞哈哈哈  阅读(113)  评论(0)    收藏  举报