Advertisement
metalx1000

Linking Buttons to Functions in Python and Qt4-designer

Jan 3rd, 2012
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.65 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. # Form implementation generated from reading ui file 'myui.ui'
  5. #
  6. # Created: Tue Jan  3 11:19:03 2012
  7. #      by: PyQt4 UI code generator 4.8.3
  8. #
  9. # WARNING! All changes made in this file will be lost!
  10.  
  11. from PyQt4 import QtCore, QtGui
  12.  
  13. try:
  14.     _fromUtf8 = QtCore.QString.fromUtf8
  15. except AttributeError:
  16.     _fromUtf8 = lambda s: s
  17.  
  18. def myfunc():
  19.     print "Hello World"
  20.  
  21. class Ui_Form(object):
  22.     def setupUi(self, Form):
  23.         Form.setObjectName(_fromUtf8("Form"))
  24.         Form.resize(400, 300)
  25.         self.pushButton = QtGui.QPushButton(Form)
  26.         self.pushButton.setGeometry(QtCore.QRect(160, 170, 88, 27))
  27.         self.pushButton.setObjectName(_fromUtf8("pushButton"))
  28.         self.label = QtGui.QLabel(Form)
  29.         self.label.setGeometry(QtCore.QRect(190, 80, 57, 15))
  30.         self.label.setObjectName(_fromUtf8("label"))
  31.  
  32.         self.retranslateUi(Form)
  33.         QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL(_fromUtf8("clicked()")), myfunc)
  34.         QtCore.QMetaObject.connectSlotsByName(Form)
  35.  
  36.     def retranslateUi(self, Form):
  37.         Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8))
  38.         self.pushButton.setText(QtGui.QApplication.translate("Form", "PushButton", None, QtGui.QApplication.UnicodeUTF8))
  39.         self.label.setText(QtGui.QApplication.translate("Form", "TextLabel", None, QtGui.QApplication.UnicodeUTF8))
  40.  
  41.  
  42. if __name__ == "__main__":
  43.     import sys
  44.     app = QtGui.QApplication(sys.argv)
  45.     Form = QtGui.QWidget()
  46.     ui = Ui_Form()
  47.     ui.setupUi(Form)
  48.     Form.show()
  49.     sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement