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 from sys import argv app = QApplication('t1') hello = QPushButton("Hello world!", None) hello.resize(100, 30) hello.show() app.run()
# parent test from Qt.Gui import QApplication, QPushButton, QWidget app = QApplication() form = QWidget() okButton = QPushButton('Push me', form) cancelButton = QPushButton('Push me', form) okButton.show() cancelButton.show() form.show() app.run()
def event(self, e): print e, e.type() return QPushButton.event(self, e)
def __init__(self, text=None, parent=None): QPushButton.__init__(self, text, parent) self.objectName = 'button' self.connect("clicked()", self.on_button_clicked)
def __init__(self, text, parent=None): QPushButton.__init__(self, text, parent)
from Qt.Gui import QApplication, QFont, QPushButton from sys import argv app = QApplication('t2') quit = QPushButton("Quit", None) quit.resize(100, 30) quit.setFont(QFont('Times', 18, QFont.Bold)); quit.connect('clicked()', app.quit); quit.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()
# simple push button from Qt.Gui import QApplication, QPushButton app = QApplication() button = QPushButton('Push me', None) button.show() print (button.x, button.y) app.run()
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()
# parent test from Qt.Core import QObject from Qt.Gui import QApplication, QPushButton app = QApplication('app') button = QPushButton('Push me', None) a = QObject(button) a.objectName = 'a' button.objectName = 'button' print button, a, a.parent() print type(button), type(a), type(a.parent()) print button == a.parent() for obj in [a, button, a.parent()]: print obj.objectName, obj
def __init__(self, parent=None): QPushButton.__init__(self, parent) self.text = 'MyButton'
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)