GUI Programming with Python—The Road Ahead

GUI Programming with Python—The Road Ahead

Talk given at PyCon APAC 2015 in Taipei, Taiwan.

9dafad54b5b4f360b7aae5f482bc1c91?s=128

Tzu-ping Chung

June 05, 2015
Tweet

Transcript

  1. The Future of GUI Programming with Python

  2. Me • Call me TP • Follow @uranusjr • https://uranusjr.com

  3. None
  4. None
  5. http://macdown.uranusjr.com

  6. www. .com

  7. Terminology • User interacts with a program through a user

    interface (UI) • A UI based on images is a graphical user interface (GUI)
  8. I want a GUI library that works. works

  9. None
  10. What I Want • Native UI and UX • Portability

    • Ease to deploy • Pythonic API
  11. What We Have

  12. Tkinter • “Python’s de-facto standard GUI” • Native nowhere •

    Themed Tk • Binding to Tcl/Tk • Lean, but may be lacking
  13. Platform-specific • PyObjC on OS X (Cocoa) • Win32API on

    Windows • PyGObject on Gnome (GTK+) • Native UI/UX • Needs to deploy C binding • Very weird API
  14. Special Interpreters • .NET via IronPython (Windows) • AWT/Swing via

    Jython • Weird API • Compatibility with other libraries
  15. Binding to Third-party • PyQt and PySide to Qt •

    wxPython to wxWidgets • Works quite natively • Cross-platform application code • Weird API • Needs to deploy tons of things
  16. “Let’s Build Everything” • Kivy and Pyglet • Cross-platform application

    code • Nice Pythonic API • Needs to deploy C binding • Not native (and they don’t care)
  17. Solution UI/UX Portable API Deploy Tkinter Meh Platform-specific Meh Jython

    Meh Meh Third-party Bindings Kivy / Pyglet Meh
  18. Licensing • GPL and LGPL • Source distribution • Static

    linking
  19. So?

  20. What I Want • Native UI and UX • Portability

    • Ease to deploy • Pythonic API
  21. The Solution (IMO) • Dynamic binding to native GUI •

    CPython compatibility • No non-Python dependencies • Wrapper API on top
  22. Native API Python API Wrapper Binding (in Python)

  23. The Binding • Foreign function interface • libffi • ctypes

    • CFFI, anyone?
  24. Native API Python API Wrapper ctypes

  25. Native API Python API Wrapper GTK+ ctypes PyGObject

  26. Native API Python API Wrapper ctypes

  27. Native API C API (e.g. CoreFoundation) Python API Wrapper ctypes

    Objective-C API ctypes + wrapper
  28. IUUQQZCFFPSHUPHB

  29. How?

  30. toga toga-win32 toga-cocoa toga-gtk … rubicon PyGObject ctypes Native GUI

    Library
  31. toga toga-win32 toga-cocoa toga-gtk … rubicon PyGObject ctypes Native GUI

    Library
  32. None
  33. None
  34. None
  35. ……

  36. None
  37. Difficulties • API design • Platform knowledge • UI Layout

  38. https://github.com/pybee/toga

  39. WHAT IF I AM INTERESTED IN SOMETHING ELSE?

  40. Did I hear mobile?

  41. lwn.net/Articles/640625/ You might also want to read this.

  42. Mobile Support • API availability • The Store • “Paradigm

    mismatch”
  43. None
  44. Python Issue #23670 Modifications to support iOS as a cross-compilation

    target
  45. None
  46. ?

  47. None
  48. None
  49. None
  50. Recap • What we have is not good enough •

    Proposed solution • Python on mobile OSs
  51. WHAT IF I AM INTERESTED IN SOMETHING ELSE?