Py Con 2016
PySide For Beginners
What We'll learn
- Qt Framework brief history
- PySide Introduction
- PySide Fundamentals
- Some Code Example
Qt Framework
Key Features
- Cross platform application framework Using C++
- Executable on various operating systems with little or none code change.
- native speed and capabilities
Supported Platforms :
- Windows/ Linux / OSX
- Embedded Windows / Linux
- iOS / Android Windows Phone
Qt Framework
Main Cores
- QtCore : Core Functionality ( database, network , data structures, thread management , etc. )
- QtGUI : Interface Widgets
Some Extentions :
- Qt Creator IDE
- QtQuick : QML for rapid UI Creation + Javascript Logic + CPP Native calls
Personal favourite :support for a subset of CSS
Qt Framework
Architechture
- Transparent, Platform Independent UI
Qt used to draw the UI from scratch in its early releases. In later versions, it uses call to native APIs
You'll never draw a button. you ask OS to draw it for you! - Signal And Slots : Implementing the Observable Pattern
Qt Framework
Free, somehow!
- Qt Framework is licensed unde LGPL.
- Free to use for non commertial usage
- paid for commertial usage ( and it's not cheap! )
Long History
- Started at 1990
- Tooltech : rise
- Nokia : Official Symbian SDK
- Sold to Digia after nokia (finally!) switched to Windows Phone OS
PySide
PySide is the Python Qt bindings project, providing access the complete Qt 4.8 framework as well as to generator tools for rapidly generating bindings for any C++ libraries.
PyQt : Almost 100% similar to PySide
- PySide : LGPL , PyQt : GLP
- Doccumentation and Support : PySide is more reliable
PySide
Why you might choose PySide/PyQt over Pure Qt
- Qt Worked hard on making core functionalities easy to use :
- Entire Qt-Specific IDE, Custom data types ( QVector, QList, .. ) ,integrated Database,
- but...
PySide
But...
- In one word : Python has almost all of it out of the box, and much easier
PySide FUNdementals
The Code we will use :
- https://github.com/Kianenigma
- each step is available on a separate commit
- clone the code, or view it online on github
HEllo wor... pyside!
- Create a minimal application window
- Set window title :
Hello PySide!
'Classing' it up
- Basically, every visual element in qt is a widget.
- Create a class that inherits from QWidget, write your own custom widget!
- Widgets can nest any other object that inherits from QWidget,
- a push button is also a widget, Nest it!
- Ref : PySide Widget Manual
classic stuff
- Some basic thing that basically every Gui framework has ( boring :| )
- Menu Bar
- Tooltip
- Toolbar
- But,
- QWidget is just a blank surface, Menu Bars and.. are applicable to QMainWindow
- Reference 1, Reference 2
ow beautiful qt!
- Basic Layout in Qt, PySide
- Absolute Positioning :
- Move, Set Geometry,
- Layouts :
Grid , Box - Lock window size, center it,..
- And Lovely CSS !
- Reference , Reference2
there is a special place in hell for you if you use absolute geometry
trust the signals you get
- Any Widget can emit signals
- Any Widget can register itself as a slot, waiting for that signal
Actually, anything inheriting from QtCore.QObject can emit and send, which is more general than QWidget! - Binding a signal and slot : .connect()
after calling app.exec_() - Override internal slots
Signals, signals everywhere
- Passing parameter to a slot with lambda
- Emitting a custom events
- Emitters might not be UI Elements,
Network Event,
Native Events,
Time Intervals, etc...
Question ?
- GitURL:
https://github.com/Kianenigma/PySideForBeginners
- Slide URL :
https://slides.com/kianpeymani/pyside
PySide - PyCon 2016
By Kian Peymani
PySide - PyCon 2016
Introduction to PySide
- 696