PySide6学习笔记--gui小模版使用

一、界面绘制

1.desiner画图

PySide6学习笔记--gui小模版使用_第1张图片

2.画图代码

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

################################################################################
## Form generated from reading UI file 't1gui.ui'
##
## Created by: Qt User Interface Compiler version 6.5.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################

from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
    QMetaObject, QObject, QPoint, QRect,
    QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
    QFont, QFontDatabase, QGradient, QIcon,
    QImage, QKeySequence, QLinearGradient, QPainter,
    QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QLabel, QLineEdit, QPushButton,
    QSizePolicy, QWidget)

class Ui_Form(object):
    def setupUi(self, Form):
        if not Form.objectName():
            Form.setObjectName(u"Form")
        Form.resize(400, 300)
        self.pushButton = QPushButton(Form)
        self.pushButton.setObjectName(u"pushButton")
        self.pushButton.setGeometry(QRect(70, 180, 75, 23))
        self.lineEdit = QLineEdit(Form)
        self.lineEdit.setObjectName(u"lineEdit")
        self.lineEdit.setGeometry(QRect(140, 110, 113, 21))
        self.label = QLabel(Form)
        self.label.setObjectName(u"label")
        self.label.setGeometry(QRect(50, 110, 53, 15))

        self.retranslateUi(Form)

        QMetaObject.connectSlotsByName(Form)
    # setupUi

    def retranslateUi(self, Form):
        Form.setWindowTitle(QCoreApplication.translate("Form", u"Form", None))
        self.pushButton.setText(QCoreApplication.translate("Form", u"PushButton", None))
        self.label.setText(QCoreApplication.translate("Form", u"TextLabel", None))
    # retranslateUi

 

2.1核心导入内容。

PySide6学习笔记--gui小模版使用_第2张图片

 

二、调界面函数

2.1调用代码

# -*- coding:utf-8 -*-
# 导入 t1gui_ui _ui
from t1gui_ui import Ui_Form
from PySide6.QtWidgets import QApplication, QMainWindow
import sys

# 继承 Ui_MainWindow类


class MyMainWindow(QMainWindow,Ui_Form):
    def __init__(self):
        super().__init__()
        self.setupUi(self)

        self.pushButton.clicked.connect(self.showDialog)

    def showDialog(self):
        self.lineEdit.setText("hello,world!")
        self.label.setText(self.lineEdit.text())
     
   


if __name__ == "__main__":
    app = QApplication(sys.argv)
    myWin = MyMainWindow()
    myWin.show()
    sys.exit(app.exec_())

2.2界面截图

PySide6学习笔记--gui小模版使用_第3张图片

 PySide6学习笔记--gui小模版使用_第4张图片

 PySide6学习笔记--gui小模版使用_第5张图片

 

你可能感兴趣的:(学习,笔记,pyqt6)