title: How do I change default text in a Qt lineEdit by entering data into the running frame in order to re-run functions with the new value?
body: <p>I am new to Python, and even more new to PyQt4. (I've created a similar GUI with wxPython, but I can't make this work.) I've spent hours trying to figure this out, and I've tried so many tips from searches here and elsewhere, including the instruction docs, that I'm dizzy.</p>
  
  <p>The window I created in Qt Designer is supposed to allow the user to enter data in QLineEdit boxes, and that data is then used in some functions to do some math and plot some graphs. To make it easy for the user - I think - I've put default values in the frame when it runs. I do not know how to allow the user to dynamically set new values (i.e., different from the default). I've tried chasing things back with a global variable to see where things go wrong, but I can't figure it out.</p>
  
  <p>I've created a much smaller version of what I'm doing (to keep it short), and the issue is the same. </p>
  
  <p>Here's a picture of the frame to help if I've failed to explain this well:
  <a href="http://i.stack.imgur.com/egREh.png" rel="nofollow">Frame screen shot</a></p>
  
  <p>And here's the code:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  
  # Form implementation generated from reading ui file 'TestWindow2.ui'
  #
  # Created by: PyQt4 UI code generator 4.11.4
  #
  # WARNING! All changes made in this file will be lost!
  
  from PyQt4 import QtCore, QtGui
  import sys
  
  my_global_var = 100
  
  try:
      _fromUtf8 = QtCore.QString.fromUtf8
  except AttributeError:
      def _fromUtf8(s):
          return s
  
  try:
      _encoding = QtGui.QApplication.UnicodeUTF8
      def _translate(context, text, disambig):
          return QtGui.QApplication.translate(context, text, disambig, _encoding)
  except AttributeError:
      def _translate(context, text, disambig):
          return QtGui.QApplication.translate(context, text, disambig)
  
  class Ui_MainWindow(object):
      global my_global_var
  
      def setupUi(self, MainWindow):
          MainWindow.setObjectName(_fromUtf8("MainWindow"))
          MainWindow.resize(514, 363)
          self.centralwidget = QtGui.QWidget(MainWindow)
          self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
          self.formLayoutWidget = QtGui.QWidget(self.centralwidget)
          self.formLayoutWidget.setGeometry(QtCore.QRect(10, 0, 501, 31))
          self.formLayoutWidget.setObjectName(_fromUtf8("formLayoutWidget"))
          self.formLayout = QtGui.QFormLayout(self.formLayoutWidget)
          self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow)
          self.formLayout.setObjectName(_fromUtf8("formLayout"))
          self.enterHereLabel = QtGui.QLabel(self.formLayoutWidget)
          self.enterHereLabel.setObjectName(_fromUtf8("enterHereLabel"))
          self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.enterHereLabel)
          self.enterHereLineEdit = QtGui.QLineEdit(self.formLayoutWidget)
          self.enterHereLineEdit.setObjectName(_fromUtf8("enterHereLineEdit"))
          self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.enterHereLineEdit)
          self.pushButton = QtGui.QPushButton(self.centralwidget)
          self.pushButton.setGeometry(QtCore.QRect(40, 80, 461, 23))
          self.pushButton.setObjectName(_fromUtf8("pushButton"))
          MainWindow.setCentralWidget(self.centralwidget)
          self.menubar = QtGui.QMenuBar(MainWindow)
          self.menubar.setGeometry(QtCore.QRect(0, 0, 514, 21))
          self.menubar.setObjectName(_fromUtf8("menubar"))
          MainWindow.setMenuBar(self.menubar)
          self.statusbar = QtGui.QStatusBar(MainWindow)
          self.statusbar.setObjectName(_fromUtf8("statusbar"))
          MainWindow.setStatusBar(self.statusbar)
  
          self.retranslateUi(MainWindow)
          QtCore.QMetaObject.connectSlotsByName(MainWindow)
  
      def retranslateUi(self, MainWindow):
          global my_global_var
          MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
          self.enterHereLabel.setText(_translate("MainWindow", "Enter here:", None))
          self.enterHereLineEdit.setText(_translate("MainWindow", "100", None))
          """ ^ Code created by Qt Designer with the default value of 100 """
          self.pushButton.setText(_translate("MainWindow", "PushThisButton", None))
          self.pushButton.clicked.connect(self.MyFunction)
  
          x = str(self.enterHereLineEdit.text()) # Seeing if I can get the value
          print("x = {0}".format(x)) # This correctly prints the default value of 100
          my_global_var = x
          print("My global var = {0}".format(my_global_var)) # Correctly -&gt; 100
  
      def MyFunction(self, MainWindow):
          global my_global_var
  
          print("My var = {0}".format(my_global_var)) # prints 100
          a = int(my_global_var)
          y = a+20
          print(y) # correctly prints 120
  
  class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
      global my_global_var
  
      def __init__(self, parent=None, f=QtCore.Qt.WindowFlags()):
          QtGui.QMainWindow.__init__(self, parent, f)
  
          self.setupUi(self)
  
  if __name__ == '__main__':
      app = QtGui.QApplication(sys.argv) 
      mw = MainWindow()
      mw.show()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>I've left the global variables and comments to show how things work. What do I need to change / do to make the user's frame entry update the calculations? (When I click the button, I get the same results regardless of whether I change the default value.)</p>