How to transfer QLineEdit value into console?

Assume we have an interface with Buttons and LineEdits in one .py file. I have this code in another, which inherits it:

import Inter_Input_Blasting as interf
from PyQt6 import QtCore,QtWidgets,QtGui
from functools import partial

class MainWindow(QtWidgets.QMainWindow):

def on_clicked(self):
    print("Button Pushed")

def __init__(self,parent=None):
    super(MainWindow, self).__init__(parent)
    self.ui = interf.Ui_MainWindow()
    self.ui.setupUi(self)
    self.ui.calc_button.clicked.connect(MainWindow.on_clicked)

    self.ui.input_overall_1.textChanged.connect(MainWindow.gather_data)


def gather_data(self):
    return self.ui.input_overall_1.text()


if __name__== "__main__":
    import sys
    app = interf.QtWidgets.QApplication(sys.argv)
    Form = MainWindow()
    Form.show()
    sys.exit(app.exec())

So, i need to print my values into console when i put it in the lineedit fiels. The .textChanged() method is working, but the .gather_data() isn’t.

Answer

In method gather_data, store the text in a variable:

def gather_data(self):
    global txt
    txt = self.ui.input_overall_1.text()

then before sys.exit, print that value:

r = app.exec()
print(txt)
sys.exit(r)

This just to show you an idea. It is probably better to have txt as a member variable of MainWindow.