Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import sys
- from PyQt4 import QtGui, QtCore
- class Example(QtGui.QMainWindow):
- def __init__ (self, parent=None):
- super(Example, self).__init__()
- self.initUI()
- def initUI(self):
- button1 = QtGui.QPushButton("Button 1", self)
- button1.move(30, 50)
- button2 = QtGui.QPushButton("Button 2", self)
- button2.move(150, 50)
- self.connect(button1, QtCore.SIGNAL('clicked()'), self.buttonClicked)
- self.connect(button2, QtCore.SIGNAL('clicked()'), self.buttonClicked)
- self.statusBar()
- self.setGeometry(300, 300, 350, 250)
- self.setWindowTitle('Example: Signal - Slot')
- self.show()
- def buttonClicked(self):
- sender = self.sender()
- self.statusBar().showMessage(sender.text() + ' was pressed');
- def main():
- app = QtGui.QApplication(sys.argv)
- qs = Example()
- sys.exit(app.exec_())
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement