(一)說在前面html
Python自帶了GUI模塊Tkinter,只是界面風格有些老舊。另外就是各類GUI框架了。
python
以前安裝過WxPython,並作了簡單的界面。遂最近又從新搜索了一下網上關於Python GUI框架的問題,發現仍是Qt呀。linux
Python的Qt有PyQt和PySide吧。PyQt 是商業及 GPL 的版權, 而 PySide 是 LGPL。大意也就是PyQt開發商業軟件是要購買受權的,而PySide則不須要。兩者代碼基本一致,修改下import 基本剩餘的代碼皆可通用。因此堅決果斷的選擇了PySide。git
接下來的這段時間,將會一邊學習Pyside,一邊學習Django更深層次的東西。若是還有時間,就再熟悉一下Python基礎的一些東西。github
(二)PySide的安裝web
(1)官網教程略顯麻煩。sql
官網: http://qt-project.org/wiki/PySide shell
(2)比較快捷省事的安裝app
dizzy@dizzy-pc:~$ sudo add-apt-repository ppa:pyside You are about to add the following PPA to your system: Official Ubuntu packages for PySide Qt Bindings. dizzy@dizzy-pc:~$ sudo apt-get update # ... ... dizzy@dizzy-pc:~$ sudo apt-get install python-pyside Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libphonon4 libpyside1.1 libqt4-help libqt4-scripttools libqt4-test libqtwebkit4 libshiboken1.1 phonon phonon-backend-gstreamer python-pyside.phonon python-pyside.qtcore python-pyside.qtdeclarative python-pyside.qtgui python-pyside.qthelp python-pyside.qtnetwork python-pyside.qtopengl python-pyside.qtscript python-pyside.qtsql python-pyside.qtsvg python-pyside.qttest python-pyside.qtuitools python-pyside.qtwebkit python-pyside.qtxml
(3)測試是否安裝成功框架
dizzy@dizzy-pc:~$ python Python 2.7.3 (default, Feb 27 2014, 20:00:17) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import PySide >>> dir(PySide) ['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '__version__', '__version_info__'] >>> PySide.__version__ '1.1.2' >>> PySide.QtCore.__version__ '4.8.1'
(三)PySide初試
# -*- coding: utf-8 -*- # 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()
這樣運行就能夠看到一個最簡單的窗口了。Hello World .
(四)PySide教程
官網教程: http://qt-project.org/wiki/PySideDocumentation
Overview of Python GUI development : http://pythoncentral.org/introduction-python-gui-development/
找到一個比較不錯的教程: http://srinikom.github.io/pyside-docs/index.html
再加一個經典書籍: http://www.commandprompt.com/community/pyqt/book1 GUI Programming with Python: QT Edition