Python GUI Programming With PySide PDF
Python GUI Programming With PySide PDF
PySide
Speaker: BigLittle
Date: 2013/03/04
CLI vs. GUI
CLI (Command Line Interface) GUI (Graphical User Interface)
Take less resources. Easier for user to view and
User have much more control your application.
control of their system. Ability of multitasking.
Only need to execute few
line to perform a task.
About Python + GUI
Some GUI library for Python:
Tkinter - Python's standard GUI package. (Tcl/Tk)
wxPython - A Python extension module that wraps wxWidgets library.
PyQt4 - A Python binding of the cross-platform GUI toolkit Qt.
PySide - A Python binding of the cross-platform GUI toolkit Qt.
Cons:
Qt is not written in standard C++ library.
Application size is big.
blabla
I dont care, and you?
Before Starting
Install Python (What?!)
http://www.python.org/download
User should note the compatibility between version 2.7.x and 3.x.
Install Qt
http://qt-project.org/downloads
The latest version is 5.0. (Its too new for me... =.=)
Install PySide
http://qt-project.org/wiki/PySideDownloads
Current version is 1.1.2, but most references on web is for 1.0.7.
A Simple Program
test.py object oriented programming styles
Just so easy!
A Simple Program (contd)
test.py
app = QApplication(sys.argv)
main = QMainWindow()
main.setWindowTitle(First GUI)
main.show()
sys.exit(app.exec_())
QHBoxLayout
QGridLayout
QVBoxLayout
QFormLayout
QWidget
Example Think: Whats the layout setting
in the QGroupBox?
Lets Put Something On It
How To Activate It?
Now you have a skin of your application. Lets make it activated.
For example, push Big button then type Bigger on the editor.
trigger response
In Qt, trigger & response are called SIGNAL & SLOT
SIGNAL / SLOT
self.btn1.clicked.connect(self.typebig)
The advantage of SIGNAL / SLOT is the caller does not have to
know anything about the receiver and vice versa.
Any function could be a SLOT.
One can connect several SLOT to a SIGNAL and vice versa.
Maintains:
CurveExpert
Debug, debug and debug. (PyInstaller)
Packing/Release:
PyInstaller - Cross platform
cx_Freeze - Cross platform
py2exe - Window only
BitTorrent
(py2exe)
Create Your Own GUI App!
Model-View-Controller
Automation Tool
Distributed Programming
Database Management
Multimedia
CAD Software
Embedded System
Web Application
Games
Summary
GUI programming could help you interactively control the
application and report visualized final data. Every programmer
should familiar with its basic concept.