[[PageOutline]] = note = * QT creater:QT 的 IDE。整合了原本 QT designed 所有的設計功能。 * PyQT:將 python 與 qt bind 在一起,支援 python 2、3。 * 4.5 版後適用 LGPL licence。 * !PySide: LGBL licence。 !PyQt 不是。 * API Reference:http://doc.trolltech.com/latest/index.html * C:/QtSDK/readme/index.html = !PySide = 1. 手冊:http://developer.qt.nokia.com/wiki/PySideDocumentation/ 1. 環境: * QT SDK * Python * !PySide 1.07 1. 測試: {{{ #!python import PySide print PySide.__version__ }}} 結果:1.0.7 1. 第一個 Hello World GUI 程式: {{{ #!python # Import PySide classes import sys from PySide.QtCore import * from PySide.QtGui import * # Create a Qt application app = QApplication(sys.argv) # Create a Label and show it label = QLabel("Hello World") label.show() # Enter Qt application main loop app.exec_() sys.exit() }}} 你也可以在 QLabel 中加入 html 語法 {{{ #!python label = QLabel("Hello World") }}} 1. 第二個程式,加入connect與程式連結: {{{ #!python #!/usr/bin/python # 載入 PySide classes import sys from PySide.QtCore import * from PySide.QtGui import * # 定義一個 say_hello 的 subroutine,這個 subroutine 會印出 Hellow World def say_hello(): print 'Hellow World' # 建立 Qt 應用程式 app = QApplication(sys.argv) # 新增一個 button button = QPushButton('test') # 將 button 與 say_hello 連結 button.clicked.connect(say_hello) # 讓 button 顯示出來 button.show() # 執行 Qt 應用程式的 main loop app.exec_() sys.exit() }}} = Reference = * http://qt.nokia.com/ 官網。 * http://ogc-daily.blogspot.com/2009/04/pyqt-part-1-introduction.html pyQT介紹