def __init__(self, parent=None): QWidget.__init__(self, parent) self.setFixedSize(200, 120) quit = QPushButton('Quit', self) quit.setGeometry(62, 40, 75, 30); quit.setFont(QFont('Times', 18, QFont.Bold)) quit.connect('clicked()', QApplication.instance().quit)
from Qt.Gui import QApplication, QPushButton class MyButton(QPushButton): def on_clicked(self): print 'on_clicked' app = QApplication('test') a = QPushButton('A', None) b = MyButton('B', None) a.connect('clicked()', b.clicked) b.connect('clicked()', b.on_clicked) a.show() b.show() app.run()
from Qt.Gui import QApplication, QFont, QPushButton, QWidget app = QApplication('t3') window = QWidget() window.resize(200, 120); quit = QPushButton ('Quit', window) quit.setFont(QFont('Times', 18, QFont.Bold)) quit.setGeometry(10, 40, 180, 40) quit.connect('clicked()', app.quit) window.show() app.run()
def __init__(self, parent=None): QWidget.__init__(self, parent) self.setFixedSize(200, 120) quit = QPushButton('Quit', self) quit.setGeometry(62, 40, 75, 30); quit.connect('clicked(bool)', self.on_clicked)