PyQt4-(4) Tutorial 2

#!/usr/bin/env python
# -*- coding:utf-8 -*-
# PyQt tutorial 2
# Modified by Wubin Qu [quwubin AT gmail.com]
# Blog: http://quwubin.cnblogs.com/
# 引入了信号(signal)和槽(slots)的概念
# 点击按钮'Quit',退出动作激活
import sys
from PyQt4 import QtCore, QtGui

app = QtGui.QApplication(sys.argv)
quit = QtGui.QPushButton("Quit")
quit.resize(75, 30)
quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
# setFont 方法改变按钮的字体,大小等
QtCore.QObject.connect(quit, QtCore.SIGNAL("clicked()"),
app, QtCore.SLOT("quit()"))
# PyQt4的事件处理时间里在信号(signals)和槽(slots)机制上的。如果我们点击了按钮,
#就发射了信号 clicked()方法。槽可以是PyQt槽,也可以是任何python中可调用的方法。
#通过使用QtCore.QObject.connect()方法将信号和槽链接起来。在这个的例子中,使用的
#槽是PyQt中预先定义的quit()槽。
quit.show()
sys.exit(app.exec_())
____________________________
屈武斌
Email: quwubin AT gmail.com
Blog: http://quwubin.cnblogs.com/
屈武斌
Email: quwubin AT gmail.com
Blog: http://quwubin.cnblogs.com/
浙公网安备 33010602011771号