Storing data from lineEdits to variables in Python

22 Views Asked by At

I have code witten as below. I am trying to achieve that user inputs numeric values and clicks a button, those values are stored in variables d1n, d2n, hn and so on.

# -*- coding: utf-8 -*-
"""
Created on Wed Nov  2 10:52:12 2022

@author: z0045yrk
"""

import sys
from PyQt5 import QtWidgets, uic, QtGui, QtCore

qtcreator_file  = "FEA_Core_App_GUI.ui" # Enter file here.
Ui_MainWindow, QtBaseClass = uic.loadUiType(qtcreator_file)


class MyApp(QtWidgets.QMainWindow, Ui_MainWindow):
    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        self.setupUi(self)
        self.pushButton_Calc.clicked.connect(self.LoadGeometryAndRun)
        
    def LoadGeometryAndRun(self):
        d1n = float(self.lineEdit_d1.text())
        d2n = float(self.lineEdit_d2.text())
        hn = float(self.lineEdit_hn.text())
        l1n = float(self.lineEdit_l1.text())
        l2n = float(self.lineEdit_l2.text())
        l3n = float(self.lineEdit_l3.text())
        l4n = float(self.lineEdit_l4.text())
        d1n = d1n
        #import Jezgra_3_2
        #Jezgra_3_2()
       # self.results_window.setText(total_price_string)




if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    window = MyApp()
    window.show()
    sys.exit(app.exec_())

if I substitute "d1n = " for instance with "print(", code would return printed user inputed value

0

There are 0 best solutions below