PyQt5_Demo2

 formhello.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>400</width>
    <height>300</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>Form</string>
  </property>
  <widget class="QLabel" name="label">
   <property name="geometry">
    <rect>
     <x>90</x>
     <y>60</y>
     <width>281</width>
     <height>91</height>
    </rect>
   </property>
   <property name="font">
    <font>
     <pointsize>17</pointsize>
     <weight>50</weight>
     <italic>false</italic>
     <bold>false</bold>
     <underline>true</underline>
    </font>
   </property>
   <property name="text">
    <string>Hello,everyHHOne!</string>
   </property>
   <property name="textFormat">
    <enum>Qt::AutoText</enum>
   </property>
   <property name="wordWrap">
    <bool>false</bool>
   </property>
   <property name="margin">
    <number>20</number>
   </property>
  </widget>
  <widget class="QPushButton" name="pushButton">
   <property name="geometry">
    <rect>
     <x>130</x>
     <y>140</y>
     <width>171</width>
     <height>41</height>
    </rect>
   </property>
   <property name="font">
    <font>
     <pointsize>15</pointsize>
    </font>
   </property>
   <property name="text">
    <string>PushButton</string>
   </property>
  </widget>
 </widget>
 <resources/>
 <connections/>
</ui>
根据formhello.ui生成的ui_FormHello.py
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'formhello.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_FormHello(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(400, 300)
        self.label = QtWidgets.QLabel(Form)
        self.label.setGeometry(QtCore.QRect(90, 60, 281, 91))
        font = QtGui.QFont()
        font.setPointSize(17)
        font.setBold(False)
        font.setItalic(False)
        font.setUnderline(True)
        font.setWeight(50)
        self.label.setFont(font)
        self.label.setTextFormat(QtCore.Qt.AutoText)
        self.label.setWordWrap(False)
        self.label.setObjectName("label")
        self.pushButton = QtWidgets.QPushButton(Form)
        self.pushButton.setGeometry(QtCore.QRect(130, 140, 171, 41))
        font = QtGui.QFont()
        font.setPointSize(15)
        self.pushButton.setFont(font)
        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.label.setText(_translate("Form", "Hello,everyHHOne!"))
        self.pushButton.setText(_translate("Form", "PushButton"))

demo2.py

##appMain1.py
##使用ui_FormHel1o.py文件中的类Ui_FormHello创建app
import sys
from PyQt5 import QtWidgets
from referencePackage.pyqt5Demos.ui_FormHello import ui_FormHello

app=QtWidgets.QApplication(sys.argv)
basewidget=QtWidgets.QWidget()#创建窗体的基类QWidget的实例

ui=ui_FormHello()
ui.setupUi(basewidget)#以basewidget作为传递参数,创建完整窗体

basewidget.show()
##ui.LabHello.setText("Hello,被程序修改")#可以修改窗体上标签的文字
sys.exit(app.exec_())

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值