(a) say in the front
Python comes with GUI module Tkinter, but the interface style is somewhat old. It is also a variety of GUI frameworks.
Previously installed Wxpython, and made a simple interface. Then recently re-searched the web about the Python GUI framework problems, found or QT ah.
Python's Qt has PYQT and pyside. PyQt is the copyright of the commercial and GPL, and Pyside is LGPL. The idea is that PYQT development of commercial software is to purchase authorization, and pyside do not need. The code is basically the same, modify the import basic remaining code can be common. So did not hesitate to choose the pyside.
(ii) Installation of Pyside
(1) relatively fast and convenient installation
dizzy@dizzy-pc:~$ sudo add-apt-repository ppa:pyside
You is 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-pysidereading package lists ... Donebuilding Dependency Tree Reading State information ... Donethe following extra packages would be installed:libphonon4 libpyside1.1 libqt4-help Libqt4-scripttools libqt4-test Lib QTWEBKIT4 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
(2) test whether the installation is successful
dizzy@dizzy-pc:~$ python
Python 2.7.3 (default, Feb, 20:00:17) [GCC 4.6.3] on Linux2type ' help ', ' copyright ', ' credits ' or ' license ' for MO Re information.
>>> Import pyside>>> dir (pyside)
Copy the Code code as follows:
[' __all__ ', ' __builtins__ ', ' __doc__ ', ' __file__ ', ' __name__ ', ' __package__ ', ' __path__ ', ' __version__ ', ' __version_ ' Info__ ']
>>> pyside.__version__
' 1.1.2 '
>>> pyside.qtcore.__version__
' 4.8.1 '
(iii) Pyside Preliminary examination
#-*-Coding:utf-8-*-# import pyside classesimport sysfrom pyside.qtcore Import *from Pyside.qtgui import * # creat E a Qt application app = Qapplication (sys.argv) # Create a Label and show Itlabel = Qlabel ("Hello World") Label.show () # Ente R Qt Application main loopapp.exec_ () Sys.exit ()
This way, you can see the simplest window. Hello World.
(d) Hello,pyside
The first example using Pyside, create a new hello.py file and enter the following:
# import pyside classes import sys from pyside.qtcore import * from Pyside.qtgui Import *
Double-click the file to run the result: