PyQt QLineEdit get value from separate .py file
<p>I have the following code in one python file (sales.py) and want to display the results of the script's calculation in a QLineEdit of a separate file (control.py).</p>

<p>All line_edit.setText(def), line_edit.dispayText(def), line_edit.setText(subtotal) are not working. Any ideas of how I could go about doing this? </p>

<p>Thanks in advance for any suggestions. </p>

<pre><code>#sales py

def main () :
    total()

def total () :

    totals = { "quantity" : 4 , "price" : 1.5}

    total_quant = totals [ "quantity" ]
    total_price = totals [ "price" ]

    subtotal = str(total_quant * total_price)

    return subtotal


 main()

--------------

#the below is not working
#controls.py

from sales import *
import sys
from PyQt4 import QtGui, QtCore

class Example(QtGui.QWidget):

    def __init__(self):
        super(Example, self).__init__()

        self.initUI()


    def initUI(self): 

       q_le = QtGui.QLineEdit(self)
       q_le.move (50,50)
       q_le.setText(total())

       self.setGeometry(300, 300, 250, 150)
       self.setWindowTitle('Line Edit')    
       self.show()

def main():

    app = QtGui.QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())


if __name__ == '__main__':
    main()
</code></pre>

<p>At the beginning I had my doubts that what I had in mind - get a script result from one py file and display it in a QLineEdit of another py file -  would ever work. With the help of more experienced developers the solution turned out to be actually quite easy. </p>

<p>In fact, my inquiries are part of a personal learning project, that is, subdivide a large script into smaller portions, saved in separate files. </p>

<p>I have updated the code already, in case others are facing similar issues. </p>

python pyqt4 qlineedit