I am using PyQT and am trying to set up a really simple program. All I want is a simple button that when clicked changes a label text to hello world.. Sorry if this is the wrong place to ask this question.. I have designed the UI in QT 4 Designer and am editing the code in Eric.

The UI code is:

Qt Code:
  1. # -*- coding: utf-8 -*-
  2.  
  3. # Form implementation generated from reading ui file 'test.ui'
  4. #
  5. # Created: Sat Jan 26 21:56:01 2013
  6. # by: PyQt4 UI code generator 4.9.1
  7. #
  8. # WARNING! All changes made in this file will be lost!
  9.  
  10. from PyQt4 import QtCore, QtGui
  11.  
  12. try:
  13. _fromUtf8 = QtCore.QString.fromUtf8
  14. except AttributeError:
  15. _fromUtf8 = lambda s: s
  16.  
  17. class Ui_Form(object):
  18. def setupUi(self, Form):
  19. Form.setObjectName(_fromUtf8("Form"))
  20. Form.resize(247, 177)
  21. self.label = QtGui.QLabel(Form)
  22. self.label.setGeometry(QtCore.QRect(60, 40, 131, 20))
  23. self.label.setObjectName(_fromUtf8("label"))
  24. self.button = QtGui.QPushButton(Form)
  25. self.button.setGeometry(QtCore.QRect(70, 100, 96, 27))
  26. self.button.setObjectName(_fromUtf8("button"))
  27.  
  28. self.retranslateUi(Form)
  29. QtCore.QMetaObject.connectSlotsByName(Form)
  30.  
  31. def retranslateUi(self, Form):
  32. Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8))
  33. self.label.setText(QtGui.QApplication.translate("Form", "Hmmm...", None, QtGui.QApplication.UnicodeUTF8))
  34. self.button.setText(QtGui.QApplication.translate("Form", "Press Me!", None, QtGui.QApplication.UnicodeUTF8))
To copy to clipboard, switch view to plain text mode 

and the main app code is:

Qt Code:
  1. import sys
  2. from PyQt4 import QtCore, QtGui
  3.  
  4. import ui_test
  5.  
  6. def clicked():
  7. designed.label.setText("Hello World!")
  8.  
  9. def main():
  10. app = QtGui.QApplication(sys.argv)
  11. designed = ui_test.Ui_Form()
  12. widget = QtGui.QWidget()
  13. designed.setupUi(widget)
  14. designed.button.clicked.connect(clicked)
  15. widget.show()
  16. sys.exit(app.exec_())
  17.  
  18. if __name__ == '__main__':
  19. main()
To copy to clipboard, switch view to plain text mode 


But when I run the program and click the button I get the error message:

The debugged program raised the exception unhandled NameError
"global name 'designed' is not defined"
File: /home/peter/Documents/qt/test/app.py, Line: 7
Break here?

So I guess its this line that is causing the problem..

Qt Code:
  1. designed.label.setText("Hello World!")
To copy to clipboard, switch view to plain text mode 

Can anyone help please