Hi guys, just starting out with Qt using PyQt, and not having a great time! Anyone help me out here... I'm trying to get a button to print "hello world". Stereotypical and unimaginative, I know, but hey, you have to start somewhere! Problem is, I click it and nothing happens! It's not even calling the function. I think my connect statement is rubbish. Can you help?
Ta,
Rich
from PyQt4 import QtCore, QtGui
class Ui_About(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(388, 336)
self.
btnOK.
setGeometry(QtCore.
QRect(130,
300,
110,
23)) self.btnOK.setObjectName("btnOK")
QtCore.
QObject.
connect(self.
btnOK, QtCore.
SIGNAL("clicked()"), self.
hello)
def hello(self):
print "hello world"
class Ui_About(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(388, 336)
self.btnOK = QtGui.QPushButton(Dialog)
self.btnOK.setGeometry(QtCore.QRect(130, 300, 110, 23))
self.btnOK.setObjectName("btnOK")
QtCore.QObject.connect(self.btnOK, QtCore.SIGNAL("clicked()"), self.hello)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def hello(self):
print "hello world"
To copy to clipboard, switch view to plain text mode
Bookmarks