I'll just give you a short intro to whet your appetite, find all details here yourself.
import sys from PyQt4 import QtCore from PyQt4 import QtGui def clicked(): print "Button Clicked" qApp = QtGui.QApplication(sys.argv) button = QtGui.QPushButton("Click Me") QtCore.QObject.connect(button, QtCore.SIGNAL('clicked()'), clicked) button.show() sys.exit(qApp.exec_())This is the old way of connecting a signal to a slot. To use the new-style support just replace line 11 with following code
button.clicked.connect(clicked)The new-style support introduces an attribute with the same name as the signal, in this case clicked.
If you need to define your own signal you'll do something like this (off the top of my head):
class X(QtCore.QObject): mySignal = QtCore.pyqtSignal(int) def emitMySignal(self): self.mySignal.emit(100)And the old way:
class X(QtCore.QObject): def emitMySignal(self): self.emit(QtCore.SIGNAL('mySignal'), 100)
IMHO the new-style support is more pythonic and you don't have to specify your signals as strings when connecting. If you use pydev (eclipse) you'll also have completion support for signals.