ボタン作成

2014/12/10

Python2.7.6, pyQt4.11

# -*- coding: utf-8 -*-

import sys
from PyQt4 import QtGui

def main():

    app = QtGui.QApplication(sys.argv)
    w = QtGui.QWidget()

    btn = QtGui.QPushButton('Button', w)
    btn.setToolTip('This is a <b>QPushButton</b> widget')
    btn.resize(btn.sizeHint())
    btn.clicked.connect(clickButton)
    btn.move(50, 50)

    w.show()
    sys.exit(app.exec_())

def clickButton():
    print("Clicked!")

if __name__ == '__main__':
    main()


参考
First Program in PyQt4
http://zetcode.com/gui/pyqt4/firstprograms/