PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction [email protected] Python...

16
PySide overview Marc Poinot (ONERA/DSNA)

Transcript of PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction [email protected] Python...

Page 1: PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction marc.poinot@onera.fr Python bindings pyQt The first to come Some services have hard coded import PyQt4 GPL

PySideoverview

Marc Poinot(ONERA/DSNA)

Page 2: PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction marc.poinot@onera.fr Python bindings pyQt The first to come Some services have hard coded import PyQt4 GPL

ONERA/PySide-2/8PySide - Introduction

[email protected]

Outline

Quite short but practical overview

▶Qt■ Toolkit overview■ Model/View

▶PySide■ pyQt4 vs PySide■ Designer & Cython■ Widget bindings■ Class reuse

Page 3: PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction marc.poinot@onera.fr Python bindings pyQt The first to come Some services have hard coded import PyQt4 GPL

ONERA/PySide-3/8PySide - Introduction

[email protected]

Qt - Facts

▶Qt is cute■ Cross platform application framework for GUI

X Window System, Windows...■ C++ kernel + many bindings

Including Python■ Release v5.3 05/2014■ License GPL+LGPL+Commercial

Contact your own lawyer...

▶Components■ Core: QtCore, QtGui...■ Specialized: QtWebKit, QtSVG, QtSQL...■ Tools : Creator, Designer...

Page 4: PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction marc.poinot@onera.fr Python bindings pyQt The first to come Some services have hard coded import PyQt4 GPL

ONERA/PySide-4/8PySide - Introduction

[email protected]

Qt - Example

Page 5: PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction marc.poinot@onera.fr Python bindings pyQt The first to come Some services have hard coded import PyQt4 GPL

ONERA/PySide-5/8PySide - Introduction

[email protected]

Python bindings

▶pyQt■ The first to come

Some services have hard coded import PyQt4■ GPL - Use only in free software

▶PySide■ Some syntactic & behavior differences■ LGPL - Use allowed in proprietary software

PySide overview hereafter mixes Qt/PySide features

Page 6: PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction marc.poinot@onera.fr Python bindings pyQt The first to come Some services have hard coded import PyQt4 GPL

ONERA/PySide-6/8PySide - Introduction

[email protected]

PySide - Facts

▶Full Python binding■ Qt classes as Python classes■ Python types as parameter types

▶Release 1.2.2 04/2014▶Reference documentation

▶Production process■ Uses many steps■ Better with setup & source management

http://pyside.github.io/docs/pyside/

Page 7: PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction marc.poinot@onera.fr Python bindings pyQt The first to come Some services have hard coded import PyQt4 GPL

ONERA/PySide-7/8PySide - Introduction

[email protected]

PySide - Production process

Designer

A.c

A.rc

uic

rcc

ui_A.pyx

Res_rc.py

cython

B.py

A.ui

W class Ui_W class WB(QWidget,Ui_W)

A.so

Page 8: PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction marc.poinot@onera.fr Python bindings pyQt The first to come Some services have hard coded import PyQt4 GPL

ONERA/PySide-8/8PySide - Introduction

[email protected]

PySide - Example

from PySide.QtCore import *from PySide.QtGui  import *from Gview import gui

import numpy as NPYimport vtkfrom os.path import splitext

class GMain(QWidget,gui.Ui_controlWindow):  # ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­  def __init__(self):     QWidget.__init__(self,None)     self.setupUi(self)     self.b_load.clicked.connect(self.b_loadOneFile)     self.b_X.clicked.connect(self.b_xaxis)  # ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­  def b_xaxis(self,pos=None):     if (self.c_mirror.isChecked()): self.setAxis(pos,­1)     else: self.setAxis(pos,1)  # ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­  def closeEvent(self, event):     print '*** Gview: close'     event.accept()

Page 9: PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction marc.poinot@onera.fr Python bindings pyQt The first to come Some services have hard coded import PyQt4 GPL

PySideoverview

Marc Poinot(ONERA/DSNA)

Page 10: PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction marc.poinot@onera.fr Python bindings pyQt The first to come Some services have hard coded import PyQt4 GPL

ONERA/PySide-2/8PySide - Introduction

[email protected]

Outline

Quite short but practical overview

▶Qt■ Toolkit overview■ Model/View

▶PySide■ pyQt4 vs PySide■ Designer & Cython■ Widget bindings■ Class reuse

Page 11: PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction marc.poinot@onera.fr Python bindings pyQt The first to come Some services have hard coded import PyQt4 GPL

ONERA/PySide-3/8PySide - Introduction

[email protected]

Qt - Facts

▶Qt is cute■ Cross platform application framework for GUI

X Window System, Windows...■ C++ kernel + many bindings

Including Python■ Release v5.3 05/2014■ License GPL+LGPL+Commercial

Contact your own lawyer...

▶Components■ Core: QtCore, QtGui...■ Specialized: QtWebKit, QtSVG, QtSQL...■ Tools : Creator, Designer...

Page 12: PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction marc.poinot@onera.fr Python bindings pyQt The first to come Some services have hard coded import PyQt4 GPL

ONERA/PySide-4/8PySide - Introduction

[email protected]

Qt - Example

Page 13: PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction marc.poinot@onera.fr Python bindings pyQt The first to come Some services have hard coded import PyQt4 GPL

ONERA/PySide-5/8PySide - Introduction

[email protected]

Python bindings

▶pyQt■ The first to come

Some services have hard coded import PyQt4■ GPL - Use only in free software

▶PySide■ Some syntactic & behavior differences■ LGPL - Use allowed in proprietary software

PySide overview hereafter mixes Qt/PySide features

Page 14: PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction marc.poinot@onera.fr Python bindings pyQt The first to come Some services have hard coded import PyQt4 GPL

ONERA/PySide-6/8PySide - Introduction

[email protected]

PySide - Facts

▶Full Python binding■ Qt classes as Python classes■ Python types as parameter types

▶Release 1.2.2 04/2014▶Reference documentation

▶Production process■ Uses many steps■ Better with setup & source management

http://pyside.github.io/docs/pyside/

Page 15: PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction marc.poinot@onera.fr Python bindings pyQt The first to come Some services have hard coded import PyQt4 GPL

ONERA/PySide-7/8PySide - Introduction

[email protected]

PySide - Production process

Designer

A.c

A.rc

uic

rcc

ui_A.pyx

Res_rc.py

cython

B.py

A.ui

W class Ui_W class WB(QWidget,Ui_W)

A.so

Page 16: PySide - LoOPS · 2020-03-04 · ONERA/PySide-5/8 PySide - Introduction marc.poinot@onera.fr Python bindings pyQt The first to come Some services have hard coded import PyQt4 GPL

ONERA/PySide-8/8PySide - Introduction

[email protected]

PySide - Example

from PySide.QtCore import *from PySide.QtGui  import *from Gview import gui

import numpy as NPYimport vtkfrom os.path import splitext

class GMain(QWidget,gui.Ui_controlWindow):  # ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­  def __init__(self):     QWidget.__init__(self,None)     self.setupUi(self)     self.b_load.clicked.connect(self.b_loadOneFile)     self.b_X.clicked.connect(self.b_xaxis)  # ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­  def b_xaxis(self,pos=None):     if (self.c_mirror.isChecked()): self.setAxis(pos,­1)     else: self.setAxis(pos,1)  # ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­  def closeEvent(self, event):     print '*** Gview: close'     event.accept()