PySide
-
Upload
openbossa -
Category
Technology
-
view
5.006 -
download
0
description
Transcript of PySide
![Page 1: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/1.jpg)
PySidePython Bindings for the Qt FrameworkMarcelo Lira - setantaMarch, 10th / Manaus - AM
![Page 2: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/2.jpg)
Prologue
![Page 3: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/3.jpg)
Who Am I?
• Paid Open Source developer (lucky me!)• Computer Engineering Undergrad• I like Python but code mostly in C++(it’s the "binding developer paradox")
• PySide / PyMaemo teammember at INdT
![Page 4: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/4.jpg)
WhoWe Are?
• INdT - Instituto Nokia de Tecnologia• openBossa - INdT’s open source stream• Known projects: Canola, Carman, PyMaemo• Friends of Qt Development Frameworks / KDE
![Page 5: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/5.jpg)
Qt Labs Americas
• openBossa initiative• Development of Qt and KDE communities on theAmericas
http://qtlabs.openbossa.org
![Page 6: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/6.jpg)
Python
"Python is the best language ever invented!" -- me
import antigravity
![Page 7: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/7.jpg)
Qt Frameworks
Cross-platform application development framework.
A little while after Nokia’s acquisition of Trolltech Qt started beingdistributed under the LGPL license.
![Page 8: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/8.jpg)
Today’s Topics
• PySide• Binding Generation• Current Status• Future
![Page 9: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/9.jpg)
![Page 10: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/10.jpg)
PySide == Python + Qt
PySide is how we call the Python bindings of the QtFramework produced by INdT/openBossa/Qt LabsAmericas and released under the LGPL license.
![Page 11: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/11.jpg)
PySideMotivation
Python bindings for Qt under the LGPL license, alignedwith the new licensing of Qt.
Make the Qt-Python bindings fithand-in-glove on the Maemo platformand devices.
Because we are the INdT.
![Page 12: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/12.jpg)
PySide Overview
• PySide: the thing that you import• libpyside: takes care of Qt signals/slots• libshiboken: helps interfacing Python with C++
![Page 13: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/13.jpg)
Binding Assembly Line
• Qt Headers: the basic information about Qt libraries comesfrom here.
• Type System files: here the binding developer modifies thecollected information to fit the Python language.
• Handwritten code: code to handle the C++ idiosyncrasiesthat could appear.
![Page 14: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/14.jpg)
AndWhy Not...?
• Cython• ctypes• Swig• SIP• SMOKE• Boost.Python• My favorite technology...
![Page 15: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/15.jpg)
Binding Generation
![Page 16: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/16.jpg)
PySide Goals
Besides delivering LGPL Python bindings for Qt, ourother important goal was to deliver the completebinding factory.
fishes + fishing rodor
PySide + Binding Generator
And we care about your fishing skills too, so we try todocument every part of the system.
![Page 17: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/17.jpg)
Binding C++ libraries
Things one must take care in the binding business:• C++ object to Python wrapper association
• Inheritance
• Multiple inheritance and casting pointers
• Implicit type conversions
• Methods with multiple signatures
• Protected methods
• Function arguments that return values
• Virtual method overrides
• Object ownership
![Page 18: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/18.jpg)
Shiboken
• Shiboken is the binding generator used to createthe PySide bindings.
• It can generate bindings not only for Qt, but forany C++ library.
• The word means nothing at all. I was trying toremember some name and instead of returning anempty string my brain made that up.
![Page 19: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/19.jpg)
Shiboken
Ok, if you really need a meaning...
• Shi: Death
• Bo: Something, someone or somewhere
• Ken: Sword
(Disclaimer: I don’t know Japanese.)
![Page 20: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/20.jpg)
Binding Generator Pedigree
![Page 21: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/21.jpg)
Boost.Python
The code created by the first Python binding generator usedBoost.Python as sugar coating over the C Python API.
In the beginning it was good because:
• Quick start
• Runtime speed
Nevertheless, there was a bad part that showed up later:
• The size problemtemplates over templates over templates ==huge binaries
• Lack of flexibilityindirect access to the C Python API became aproblem when flexibility was needed.
![Page 22: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/22.jpg)
Binding Assembly Line (Again)
• API Extractor: collects information from library headers, merges it withthe modifications and handwritten code defined in the type systemdescription.
• Generator Runner: dynamic loader of generator front-ends.
• Shiboken: generator front-end that outputs CPython source code.
![Page 23: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/23.jpg)
libshiboken
Bindings generated with Shiboken will also needlibshiboken (which is LGPL, by the way).
libshiboken helps with:• Association of C++ objects
with Python wrappers• Multiple inheritance• Implicit type conversions• Virtual method overrides• Object ownership
![Page 24: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/24.jpg)
The Type SystemDescription
<typesystem package="sample">
<primitive-type name="int"/>
<primitive-type name="Complex" target-lang-api-name="PyComplex">
<conversion-rule file="complex_conversions.h"/>
<include file-name="complex.h" location="global"/>
</primitive-type>
<namespace-type name="SampleNamespace"/>
<value-type name="Number" />
<value-type name="SimpleFile">
<modify-function signature="open()">
<modify-argument index="return">
<remove-argument/>
</modify-argument>
<inject-code class="target" position="end" file="simplefile_glue.cpp"/>
</modify-function>
</value-type>
</typesystem>
![Page 25: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/25.jpg)
Current Status
![Page 26: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/26.jpg)
Getting Rid of Boost.Python
Die Boost.Python!
Die!
![Page 27: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/27.jpg)
Working Qt Modules
• QtCore
• QtGui(almost done)
• QtNetwork and QtSvg(community effort! Go cgoncalves!)
• QtWebkit
• QtTest
![Page 28: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/28.jpg)
And NowWhat?
• Bug FixingA couple of important generator bugs must befixed.
• ReleaseWe intend to release the Shiboken generatedPySide in a month from now.
![Page 29: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/29.jpg)
Future
![Page 30: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/30.jpg)
Better Generation Process
Help others to help themselves.
• A tool to quick start binding development.• A visual binding creation/editing tool.(Perhaps a QtCreator plugin.)
![Page 31: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/31.jpg)
The Other Side
Our focus is on Maemo but there are other worlds wecare about.
• Linux Distros: were taken care by the community(Cheers to odyx! And to chaz6 for the build patches.)
• MacOS X: it needs a little love. Anyone with a goodheart and a white laptop?
• Microsoft Windows: some work is already done,but still needs love. Lovers?
![Page 32: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/32.jpg)
Pythonization
One of PySide requisites was to beAPI compatible with PyQt4.
But we want to make PySide’s API more Pythonic.
Great, but... what makes something Pythonic?
What is good?What is right?What is real?
![Page 33: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/33.jpg)
PSEPs
PySide Enhancement Proposals
• Inspired by Python’s PEPs.
• Discussed with the community.
![Page 34: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/34.jpg)
Questions?
![Page 35: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/35.jpg)
Directions
www.pyside.org
http://lists.openbossa.org/listinfo/pyside
#pyside at Freenode
http://qt.gitorious.org/pyside
Marcelo Lira (setanta)[email protected]
![Page 36: PySide](https://reader033.fdocuments.in/reader033/viewer/2022052504/554936d9b4c9050a4d8b4777/html5/thumbnails/36.jpg)
Thanks
:)