测试功能
py文件
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'untitled.ui'
#
# Created by: PyQt5 UI code generator 5.15.6
#
# 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.
shu =0
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(600, 420)
self.label = QtWidgets.QLabel(Form)
self.label.setGeometry(QtCore.QRect(70, 140, 281, 16))
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(Form)
self.label_2.setGeometry(QtCore.QRect(160, 140, 121, 21))
self.label_2.setText("")
self.label_2.setObjectName("label_2")
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(110, 240, 75, 23))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(Form)
self.pushButton_2.setGeometry(QtCore.QRect(500, 100, 75, 23))
self.pushButton_2.setObjectName("pushButton_2")
self.lineEdit = QtWidgets.QLineEdit(Form)
self.lineEdit.setGeometry(QtCore.QRect(380, 100, 113, 20))
self.lineEdit.setObjectName("lineEdit")
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", "你要显示的值"))
self.pushButton.setText(_translate("Form", "显示"))
self.pushButton.clicked.connect(self.xianshi)
self.pushButton_2.setText(_translate("Form", "修改"))
self.pushButton_2.clicked.connect(self.xg)
self.lineEdit.setText(_translate("Form", "你要修改的值"))
def xianshi(self):
self.label_2.setText(str(shu))
def xg(self):
global shu
po = self.lineEdit.text()
shu=po
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
widget = QtWidgets.QWidget()
ui = Ui_Form()
ui.setupUi(widget)
widget.setWindowTitle("天天向上")
widget.show()
sys.exit(app.exec_())