PyQt Application Development On Maemo


Published on

Introduction to underlying technologies, the rationale of using Python and Qt as a development platform on Maemo and a short demo of a few projects built with these tools. Comparison of different bindings (PyQt vs PySide). PyQt/PySide development environments, how to develop most efficiently, how to debug, how to profile and optimize, platform caveats and gotchas.

Published in: Technology
1 Comment
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

PyQt Application Development On Maemo

  1. 1. PyQt application development on Maemo Attila Csipa [email_address] attila77 on
  2. 2. Components Python Qt
  3. 3. Python Object oriented rapid prototyping language Not just for scripting Easy to read and learn, almost like “pseudo-code” Suitable as first language Extensible (add new modules) - C/C++/whatever Embeddable in applications Open Source License (OSI Certified) Mature Large userbase and user community Plenty of good documentation and books
  4. 4. Qt Cross platform framework (Win/Mac/X11, soon S60) Native look and feel Modular (Core, GUI, Network, OpenGL, SQL, WebKit, etc) Mature Internationalization Excellent documentation Available under both commercial and Open Source licenses
  5. 5. Linux (Debian) based software platform Developed by Nokia Optimized for pocketable devices Current (Maemo 5) UI based on GTK+/Hildon Next generation UI (Maemo 6) based on Qt
  6. 6. How to connect these components ? PyQt PyMaemo Maemo Qt4
  7. 7. PyMaemo python-mafw - Python bindings for the Media Application Framework python-hildondesktop - Python bindings for the home/status widgets API python-notify - Python bindings for libnotify pyclutter (0.8.0-1maemo2) - Python bindings for the Clutter API gnome-python (2.26.1-1maemo1) pygtk (2.12.1-6maemo7) pygame gst0.10-python - GStreamer python-central ( python-osso python-hildon (0.9.0-1maemo10) etc... Current PyMaemo (Python for Maemo) is based on Python 2.5.4
  8. 8. Python Qt Bindings – API Compatible ! PyQt import PyQt4 Independent Commercial and GPL Mature Qt3 and Qt4 Binding generator: SIP Multiplatform (Win/Mac/Linux) Supports Pythons 2.3 - 3.1 PySide import PySide Nokia Sponsored LGPL New Qt4 Boost::Python and Shiboken Currently Linux only – will be multiplatform Python 2.5-2.6 Considerably larger disk and memory footprint
  9. 9. Maemo Qt4 Based on Linux/X11 version of Qt Hildon IM as default Input method Native styling Hardcoded Keys in QMainWindow (Fullscreen, Menu, Zoom) Widget/QObject special properties ... Maemo Qt API applies to PyQt applications, too !
  10. 10. Hello world <ul><li>from PyQt4 import QtGui
  11. 11. import sys
  12. 12. app = QtGui.QApplication(sys.argv)
  13. 13. label = QtGui.QLabel(“Hello world !”)
  14. 14.
  15. 15. sys.exit(app.exec_()) </li></ul>
  16. 16. More examples, tutorials Official tutorials and examples have been ported from C++ to Python python-qt4-doc (in examples dir) pyside-examples (tar.gz archive)
  17. 17. Integrated Development Environments You already have a favourite Python IDE ? Use it ! Multiplatform means you can use anything, Eric4, IDLE, Komodo, SPE... Downside – Maemo specific APIs or modules are difficult to test On device development Geany iPython Maemo oriented (can run and debug applications directly on a maemo device) Eclipse (pluthon) WingIDE Pro/OSS
  18. 18. PluThon Three layers Eclipse platform - popular and extensible framework for developing IDEs, Maemo IDE Common Architecture (MICA), a plugin framework supporting both the ESbox and PluThon products, which provides an extensible platform for Maemo development ( ): Unified project model, with C/C++ and Python implementations Linux development (e.g. Debian packaging) Support for copying files or mounting a project to run, debug, and profile programs on Maemo devices PluThon product - a targeted set of product plugins, providing the top-level project and import wizards, this help, graphics, and user interface modifications giving Pluthon its unique feel as a product.
  19. 19. PluThon In PluThon 2nd edition, you can: <ul><li>Run on latest Ubuntu distribution, Windows XP/Vista and Mac OS X Leopard (Intel)
  20. 20. Easily connect to your device with predefined connections for USB, WLAN, and Bluetooth
  21. 21. SBRSH host support
  22. 22. Explore your device using the Remote System Explorer
  23. 23. Generate and install Debian packages
  24. 24. Templates for the most common type of maemo applications
  25. 25. Develop application directly on the Internet Tablet
  26. 26. Debug application on the Internet Tablet
  27. 27. Convert projects for PluThon or create new PluThon projects
  28. 28. Run PlutThon applications directly on Internet Tablet, through SSH and SCP, transparently
  29. 29. View the output of the application on the Console View
  30. 30. Profile applications with OProfile
  31. 31. Trace library and system calls with Ltrace </li></ul>
  32. 32. Pluthon in action
  33. 33. PluThon problems ? Do you have Java installed ? Check Python version – best if matching (=2.5) Have you installed maemo-pc-connectivity on the tablet ? Have you installed x11vnc on the tablet ?
  34. 34. Pyqtoreader 100% PyQt Multithreaded 'Online' mindset Plugin oriented QGraphicsView based
  35. 35. Pyqtoreader – ebook mode
  36. 36. Maemo PyQt application considerations Startup time Execution speed Size Packaging
  37. 37. Startup time C++ example startup: 3.48 sec First run of python version: 7.6 sec Subsequent runs: 6.5 sec Using loader script: 5.8 sec
  38. 38. Startup time Using a loader script def main(): app = QtGui.QApplication(sys.argv) scene = QtGui.QGraphicsScene() view = QtGui.QGraphicsView(scene) ... sys.exit(app.exec_()) app = QtGui.QApplication(sys.argv) scene = QtGui.QGraphicsScene() view = QtGui.QGraphicsView(scene) ... sys.exit(app.exec_()) import app app.main()
  39. 39. Execution speed How does native C++ code compare to Python ? C++ Python
  40. 40. Execution speed If not thought through, can be significatly slower – is there a solution ? Use Qt calls and objects whenever possible Avoid conversions between Python and Qt objects (like str vs QString) Avoid Python slots on high frequency calls Use OpenGL ES acceleration if available If still not good enough, use external code for critical functions
  41. 41. Execution speed class quickQGraphicsView(QGraphicsView):     def __init__(self, *arg):         QGraphicsView.__init__(self, *arg)         try:             from PyQt4.QtOpenGL import QGLWidget             glwidget = QGLWidget()             if glwidget.isValid():                 self.setViewport(glwidget)         except Exception, e:             logging.warning(&quot;OpenGL acceleration not available %s&quot;, e) Don't need to know OpenGL ES to use hardware acceleration !
  42. 42. Application size Python source is compact, your packages will be small Users need to download bindings (all modules ~50 MB) Use native format resources (jpg/png)
  43. 43. Deployment Copy PY2DEB
  44. 44. Why choose Python + Qt on Maemo ? No scratchbox needed No SDK needed Multiplatform (win/mac/linux) No cross-compilation IDE support Not niche technology Fast development cycle First class Qt citizen Future proof Well documented Already has a vibrant community Python is fun !
  45. 45. Why NOT choose Python + QT on Maemo Every last drop of CPU performance needed Memory requirements Startup time is critical Using libraries without proper bindings
  46. 46. Questions ?
  47. 47. Thank you ! PyQt application development on Maemo Attila Csipa [email_address] attila77 on