您的位置:首页 > 汽车 > 时评 > 网站建站无锡_免费自动网页生成器_太原seo管理_排名推广网站

网站建站无锡_免费自动网页生成器_太原seo管理_排名推广网站

2025/4/19 15:12:15 来源:https://blog.csdn.net/weixin_55887103/article/details/144885159  浏览:    关键词:网站建站无锡_免费自动网页生成器_太原seo管理_排名推广网站
网站建站无锡_免费自动网页生成器_太原seo管理_排名推广网站
  • PromoteLabelTest.py 提升的类
import sys
from PyQt5.QtWidgets import QApplication, QWidget,QVBoxLayout,QTextEdit,QPushButton,QHBoxLayout,QFileDialog,QLabelclass PromoteLabel(QLabel):def __init__(self,parent = None):super().__init__(parent)self.setText("111111")self.setStyleSheet("background-color:rgb(100,100,100);")
  • T.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"><class>Form</class><widget class="QWidget" name="Form"><property name="geometry"><rect><x>0</x><y>0</y><width>520</width><height>431</height></rect></property><property name="windowTitle"><string>Form</string></property><widget class="PromoteLabel" name="label"><property name="geometry"><rect><x>70</x><y>120</y><width>111</width><height>61</height></rect></property><property name="text"><string/></property></widget><widget class="QPushButton" name="pushButton"><property name="geometry"><rect><x>260</x><y>200</y><width>75</width><height>23</height></rect></property><property name="text"><string>PushButton</string></property></widget></widget><customwidgets><customwidget><class>PromoteLabel</class><extends>QLabel</extends><header>PromoteLabelTest</header></customwidget></customwidgets><resources/><connections/>
</ui>
  • Ui_T.py   .ui生成的
# -*- coding: utf-8 -*-# Form implementation generated from reading ui file 'c:\Users\481073\Desktop\new\test.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, QtWidgetsclass Ui_Form(object):def setupUi(self, Form):Form.setObjectName("Form")Form.resize(520, 431)self.label = PromoteLabel(Form)self.label.setGeometry(QtCore.QRect(70, 120, 111, 61))self.label.setText("")self.label.setObjectName("label")self.pushButton = QtWidgets.QPushButton(Form)self.pushButton.setGeometry(QtCore.QRect(260, 200, 75, 23))self.pushButton.setObjectName("pushButton")self.retranslateUi(Form)QtCore.QMetaObject.connectSlotsByName(Form)def retranslateUi(self, Form):_translate = QtCore.QCoreApplication.translateForm.setWindowTitle(_translate("Form", "Form"))self.pushButton.setText(_translate("Form", "PushButton"))
from PromoteLabelTest import PromoteLabel
  • Public_Ui_test.py    逻辑层
from Ui_T import *
from PyQt5.QtWidgets import QApplication, QWidget,QVBoxLayout,QTextEdit,QPushButton,QHBoxLayout
from PyQt5.QtWidgets import QLabelclass LogicalLabel(Ui_Form,QWidget):def __init__(self,parent = None):super().__init__(parent)self.initUI()def initUI(self):self.setupUi(self)self.label.setText("22222")
  • main.py   主函数
import sys
from PyQt5.QtWidgets import QApplication, QWidget,QVBoxLayout,QTextEdit,QPushButton,QHBoxLayout
from Public_Ui_T import *class Demo(QWidget):def __init__(self):super(Demo, self).__init__()self.initUI()def initUI(self):self.setWindowTitle("...")self.resize(1200, 600)Vlayout = QVBoxLayout()MyLabel = LogicalLabel()Vlayout.addWidget(MyLabel)self.setLayout(Vlayout)if __name__ == "__main__":app = QApplication(sys.argv)main = Demo()main.show()sys.exit(app.exec_())

  • 效果

7cc3f0cc88d74c059c7d7a2e46106a03.png

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com