Python Desktop Application Development

Python Desktop Application Development

Slides of the Python Desktop Application Development Talk @ The Brainport Eindhoven Python Meetup Group Meeting #2



Therry van Neerven

November 11, 2014


  1. Python Desktop Application Development Therry van Neerven The Brainport Eindhoven

    Python Meetup Group Meeting #2 9-11-2014
  2. Where is the presentation about? • My journey of building

    the SendCloud Client. • The frameworks and tools that I’ve used and some of the inner workings. • How I would do it differently the next time.
  3. The SendCloud Client • A tool which allows you to

    scan invoices and packing slips in order to get the right label for the postal package right out of your printer within a few seconds.
  4. Motivations to build a desktop application • A high performance

    (user interface). • The native look of the OS. • Do things that can’t be done from within a browser like printing without a dialog.
  5. Motivations to build a desktop application in Python. • I

    wanted to learn more about Python. • Python allowed me to work quickly. • There are a lot of libraries available which allowed me to integrate features very fast. (Requests, PyWin32, PyUSB)
  6. GUI frameworks • Tkinter • WxPython (WxWidgets) • PyQt, PySide

    • PyGTK • Kivy
  7. GUI frameworks Interesting ones PyQt/PySide + Active development (PyQt, PySide

    is behind.) + Many features including like printing, webkit view etc. - PyQt requires some licensing costs when releasing commercially. Kivy + Android, iOS and all major desktop platforms + Build on PyGame (OpenGL), MIT license and “innovative UI” oriented. - Less features included and not native looking.
  8. Tutorials on how to build apps Kivy Pong game:

    Building a tekst editor with PyQt: Various GUI related tutorials (older, but nice to start with): Get your hands dirty!
  9. “Freezing” your application • You compile your Python scripts to

    bytecode. • Put them in a (zip) folder. • You append the zip folder to a Python Interpreter. • You place the Python Interpreter in a folder where it can find all the other dependencies like Qt and your funny kitten images.
  10. Freezing packages • CX_Freeze • Nuitka (C++ Compiler with freezing

    options. It can hide your code better) • Py2exe (Site is outdated, but seems to be active again) • WARNING: Freezing may be difficult, always start with a small project.
  11. Cross platform building • Freezing is very similair on every

    platform. (Mobile excluded) • However you need to freeze the package on the same OS as the target OS. • Virtual machines! (Vagrant) • Script your build process. You will build your app very often! • Wine(Bottler) may work. • •
  12. Installers and updating the app Installers (Windows): • Inno Setup

    • NSIS • Pynsist (Install Python and your app without having to freeze) Updating: • Simple: Create a new installer for every build. • Esky
  13. Hints and tricks • Choose the GUI framework that fits

    your needs. Frameworks like Qt are very powerful, but also very complicated when you want to do more advanced tasks. • Automate the things you do very often. Makefiles or small Python scripts can save you hours of typing and clicking. • Not every framwork or package is mature. Discuss the issues you have on GitHub and StackOverflow.
  14. The good and the bad of the application + It

    works! + Very interesting experience - Cross platform compatibility - Maintainability
  15. How it can be done better. “Do things that can’t

    be done from within a browser like printing without a dialog.”
  16. Modern web apps are awesome. • AngularJS, Knockout, EmberJS allow

    you to make high quality front-end interfaces. • JavaScript, HTML, CSS. My collegues know about this! • “For Mozilla, anything that the Web can’t do, or anything that the Web is not faster and better at than native technologies, is a bug.” – Andreas Gal, CTO Mozilla.
  17. The browser can do many things, but not everything…

  18. Webbrowser – local server Webbrowser (AngularJS App) Desktop Application With

    REST API or Websocket based RPC Online server Online Local* ws:// Action: Print Document x Get Document x as Base64 Encoded String‘com.blabla.pinter’, base64_encoded_document).then(…); Python magic to print the document with Qt (Wamp, WS implementation) (Simple HTTP server) (Web microframework)
  19. Embedded webbrowser options • Qt Webkit • Not the newest

    version. • You can link Qt signal and slots to JavaScript. • Chrominium Embedded Framework • Embed a version of “Chrome” in your app. • Complicated and not mature yet for Python.
  20. More info, help, support or a job: