Slide 1

Slide 1 text

GUI Programming with Python

Slide 2

Slide 2 text

Me • Call me TP • Follow @uranusjr • https://uranusjr.com 2

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

www. .com

Slide 5

Slide 5 text

http://macdown.uranusjr.com

Slide 6

Slide 6 text

GUI Programming with Python

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Are you sure?

Slide 10

Slide 10 text

Web application?

Slide 11

Slide 11 text

Why • Native features • Nice Appearance • Easier access 11 Why Not • Platform-specific • Difficult to learn • Deployment

Slide 12

Slide 12 text

GUI frameworks are not really Python

Slide 13

Slide 13 text

Native behaviour matters

Slide 14

Slide 14 text

http://qt-project.org

Slide 15

Slide 15 text

Qt • Pronounced as “cute” • Cross-platform • C++ (plus code generator) 15

Slide 16

Slide 16 text

Application Framework • Core utility types • GUI components • Multimedia, networking, etc. 16

Slide 17

Slide 17 text

PyQt • Riverbank Computing • Qt 5 + Python 2/3 • Qt 4 + Python 2 • GPL or commercial 17 PySide • Nokia → community • Qt + Python 2 • LGPL

Slide 18

Slide 18 text

Installation • Windows: pyqt.sourceforge.net • OS X: brew  install  pyqt5 • Linux: Use the force package manager 18

Slide 19

Slide 19 text

If you haven’t done it yet, it’s too late.

Slide 20

Slide 20 text

The Run Loop 20 Launch Initialise W ait for events Handle events Quit

Slide 21

Slide 21 text

Launch Initialise W ait for events Handle events Quit The Run Loop 21

Slide 22

Slide 22 text

Demo #1 I’m using PyQt 5.3 on OS X. Source: https://gist.github.com/uranusjr/f55c8a5622c80c29732a

Slide 23

Slide 23 text

Qt Widgets • Not covering QML today • Basic GUI components • “Top level” vs “Child widgets” 23

Slide 24

Slide 24 text

Demo #2 Widgets within widgets are children of widgets. Source: https://gist.github.com/uranusjr/f55c8a5622c80c29732a

Slide 25

Slide 25 text

Signals & Slots • When something happen, a signal is emitted • Slots can be connected to signals • When a signal emits, all slots connected to it are called 25

Slide 26

Slide 26 text

Demo #3 Simon says: Open sesame! Source: https://gist.github.com/uranusjr/f55c8a5622c80c29732a

Slide 27

Slide 27 text

Layouts • Horizontal, vertical, grid • Alignment, ratio, fill rule • Nest them to create complex layouts! 27

Slide 28

Slide 28 text

Demo #4 Get your widgets in a row. Or a column. Or whatever you wish. Source: https://gist.github.com/uranusjr/f55c8a5622c80c29732a

Slide 29

Slide 29 text

Qt Essentials • Basic modules • Core, Test • Modules based on other libraries • Multimedia, Network, SQL, WebKit • GUI modules • Widgets, Utility Widgets, QML, Quick 29

Slide 30

Slide 30 text

Demo #5 Qt unleashed. Source: https://gist.github.com/uranusjr/f55c8a5622c80c29732a

Slide 31

Slide 31 text

How Does It Work? • Qt written in C++ • Compiled libraries • Bindings created by SIP • Python program 31

Slide 32

Slide 32 text

http://setanta.wordpress.com/binding-c/

Slide 33

Slide 33 text

Usage Issues • Deployment • Platform-dependent • pyqtdeploy • Licensing • GPL or commercial 33

Slide 34

Slide 34 text

PyQt • Riverbank Computing • Qt 5 + Python 2/3 • Qt 4 + Python 2 • GPL or commercial 34 PySide • Nokia → community • Qt + Python 2 • LGPL Mostly compatible

Slide 35

Slide 35 text

Resources • http://pyqt.sourceforge.net/Docs/PyQt5/ • http://qt-project.org/doc/qt-5/ • Learn to read (some) C++!! 35

Slide 36

Slide 36 text

Don’t Like It? • IronPython, PyObjC • PyGTK+, wxPython • Kivy • Toga 36

Slide 37

Slide 37 text

FIRE QUESTIONS