想要實作將引數在lineEdit顯示的功能
在其他檔案中使用改函式卻報錯,錯誤如下

yysqt中print_text函式如下

發現缺少了這一行代碼 如果加上這一行代碼 那么就不會報錯,但是還是無法實作將引數傳遞給lineEdit的功能 ,求大神指教

uj5u.com熱心網友回復:
加上最后一行代碼,是將按鍵進行系結,但是按鍵發出信號以后文本值變化一次,就不在改變了?我在想可不可以自定義槽函式只要引數發生改變就將文本進行改變?uj5u.com熱心網友回復:
yysqt中代碼# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'untitled.ui'
#
# Created by: PyQt5 UI code generator 5.13.0
#
# WARNING! All changes made in this file will be lost!
from settings import Settings
import yys
from PyQt5 import QtCore, QtGui, QtWidgets
import threading
class Ui_YYS(object):
def setupUi(self, YYS):
YYS.setObjectName("YYS")
YYS.resize(533, 297)
self.centralwidget = QtWidgets.QWidget(YYS)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(190, 110, 114, 51))
self.pushButton.setObjectName("pushButton")
self.pushButton.pressed.connect(self.click_success)
# self.pushButton.pressed.connect(self.print_text)
self.textBrowser = QtWidgets.QTextBrowser(self.centralwidget)
self.textBrowser.setGeometry(QtCore.QRect(11, 11, 508, 90))
self.textBrowser.setObjectName("textBrowser")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(101, 220, 291, 20))
self.label.setObjectName("label")
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(10, 180, 501, 31))
self.lineEdit.setObjectName("lineEdit")
YYS.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(YYS)
self.menubar.setGeometry(QtCore.QRect(0, 0, 533, 26))
self.menubar.setObjectName("menubar")
YYS.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(YYS)
self.statusbar.setObjectName("statusbar")
self.lineEdit.textChanged.connect(self.print_text)
YYS.setStatusBar(self.statusbar)
self.retranslateUi(YYS)
QtCore.QMetaObject.connectSlotsByName(YYS)
def retranslateUi(self, YYS):
_translate = QtCore.QCoreApplication.translate
YYS.setWindowTitle(_translate("YYS", "陰陽師腳本"))
self.pushButton.setText(_translate("YYS", "點擊開始"))
self.textBrowser.setHtml(_translate("YYS", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'SimSun\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">使用說明!!!</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">1:使用雷電模擬器打開陰陽師并且將模擬器設定解析度為 </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"> ***平板版 960x540</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">2:將游戲視窗放螢屏的左上角,并且不要遮擋游戲視窗</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">3: 完成上述操作以后點擊開開始</p>\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"> ******作者:BingYiii 聯系qq:981725514 ****</p></body></html>"))
self.label.setText(_translate("YYS", "作者:BingYIII 聯系方式:qq981725514"))
def click_success(self):
text = self.pushButton.text()
if text == "點擊開始":
self.pushButton.setText("點擊停止")
Settings.set_run(1)
t = threading.Thread(target=yys.yys_run)
t.start()
if text == "點擊停止":
self.pushButton.setText("點擊開始")
Settings.set_run(0)
def print_text(self,STR):
# text = Settings.get_text()
# print(text)
self.lineEdit.setText(str(STR))
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/98063.html
