为什么 editText 不显示 Python class 中的用户输入?

Why the editText doesn't show the user input in Python class?

我有一个显示 window 的 Python class,其中包含 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_())

您没有将单击按钮事件连接到该函数 - 绑定在一个从未被调用的函数中。

只需在 class 初始化中连接您的按钮:

class path_window(pathmsgbox.Ui_PathMSGbox):


    def __init__(self,windowObject ):
        self.windowObject = windowObject
        self.setupUi(windowObject)
        self.windowObject.show()
        self.PathOpenBtn.clicked.connect(self.getText)
        self.getText()