我有一个 Python 类,它显示一个包含 2 个文本字段和 2 个按钮的窗口。
用户在第一个编辑文本中输入字符串并单击(打开按钮)时,第二个编辑文本将显示用户输入。
问题是单击按钮时,文本字段中没有显示任何内容。
代码:
'''
1- import the libraries from the converted file
2- import the converted file
'''
from PyQt5 import QtCore, QtGui, QtWidgets
import pathmsgbox
import os
import pathlib
class path_window(pathmsgbox.Ui_PathMSGbox):
def __init__(self,windowObject ):
self.windowObject = windowObject
self.setupUi(windowObject)
self.windowObject.show()
self.getText()
'''
get the userInput from the EditLine
'''
def getText(self):
inputUser = self.pathEditLine.text()
outPutUser = self.outputPathName.setText(inputUser)
print(outPutUser)
def puchBtn(self):
openButton = self.PathOpenBtn.clicked.connect(self.getText)
'''
function that exit from the system after clicking "cancel"
'''
def exit():
sys.exit()
'''
define the methods to run only if this is the main module deing run
the name take __main__ string only if its the main running script and not imported
nor being a child process
'''
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
PathMSGbox = QtWidgets.QWidget()
pathUi = path_window(PathMSGbox)
pathUi.pathCancelBtn.clicked.connect(exit)
sys.exit(app.exec_())