title: PyQt : accessing elements from outside the class
body: <p>First of all, I'd like to state that my question is very similar to this: <a href="https://stackoverflow.com/questions/16000361/accessing-gui-elements-from-outside-the-gui-class">Accessing GUI elements from outside the GUI class</a> . But since I am a newby in pyQt, I would like some more help.</p>
  
  <p>I have the design.py file, exported from Qt Designer</p>
  
  <pre><code># -*- coding: utf-8 -*-
  
  from PyQt4 import QtCore, QtGui
  
  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):
      def setupUi(self, MainWindow):
          MainWindow.setObjectName(_fromUtf8("MainWindow"))
          MainWindow.resize(150, 94)
          self.centralwidget = QtGui.QWidget(MainWindow)
          self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
          self.lineEdit = QtGui.QLineEdit(self.centralwidget)
          self.lineEdit.setGeometry(QtCore.QRect(20, 10, 113, 27))
          self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
          self.pushButton = QtGui.QPushButton(self.centralwidget)
          self.pushButton.setGeometry(QtCore.QRect(30, 40, 85, 27))
          self.pushButton.setObjectName(_fromUtf8("pushButton"))
          MainWindow.setCentralWidget(self.centralwidget)
          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):
          MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
          self.pushButton.setText(_translate("MainWindow", "PushButton", None))
  </code></pre>
  
  <p>which is imported into the main class:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  
  from PyQt4 import QtGui, QtCore
  import sys
  import design
  
  class ExampleApp(QtGui.QMainWindow, design.Ui_MainWindow):
      def __init__(self, parent=None):
          super(ExampleApp, self).__init__(parent)
          self.setupUi(self)
          self.pushButton.clicked.connect(self.button_function)
  
      def button_function(self):
          self.lineEdit.setText('results') 
  
  def main():
      app = QtGui.QApplication(sys.argv)
      form = ExampleApp()
      form.show()
      app.exec_()        
  
  if __name__ == '__main__':
      main()      
  </code></pre>
  
  <p>So far, so good. I have created a window in which I press a pushButton and a message appears in the editLine.</p>
  
  <p>This is what I want to achieve: I want the pushButton to trigger a function outside the class <em>(easy)</em>, and that function to deliver the message to the edilTLine <em>(hard)</em>. Something like this:   </p>
  
  <pre><code>    def button_function(self):
          calculations()
  
  def calculations():
      # somehow ...
      self.lineEdit.setText('results') 
  
  def main():
      app = QtGui.QApplication(sys.argv)
      form = ExampleApp()
      form.show()
      app.exec_()        
  
  if __name__ == '__main__':
      main()      
  </code></pre>
  
  <p>Any thought would be appreciated.  </p>