我有两个python文件,一个叫做“ myInterface.py”,其中包含用PyQt5制作并用pyuic5转换过的GUI,另一个是“ functions.py”来执行操作。
第一个:
myMessage = None
def setMessage(message):
myMessage = message
Ui_Dialog.writeMessage(message)
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(640, 560)
self.textEdit_2 = QtWidgets.QTextEdit(Dialog)
self.textEdit_2.setGeometry(QtCore.QRect(10, 320, 291, 211))
self.textEdit_2.setReadOnly(True)
self.textEdit_2.setObjectName("textEdit_2")
#buttons, labels, etc
在Ui_Dialog类中,我具有以下功能:
def writeMessage(self,message):
self.textEdit_2.append(message)
在第二个文件中,我尝试在第一个文件中写一条消息:
def checkDirectory(directory):
os.chdir(directory)
print("Checking folder")
#here i want to send the message above
myInterface.setMessage("Checking folder")
我遇到以下错误:
AttributeError: 'str' object has no attribute 'textEdit_2'