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).
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?
Thanks in advance for any suggestions.
#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()