Building Desktop Apps with wxPython
Episode Deep Dive
Guest Introduction and Background
Mike Driscoll is a longtime Python developer who is passionate about building desktop applications and sharing his knowledge through books, tutorials, and open-source contributions. He has authored multiple Python books, including those covering wxPython, ReportLab, and Python 101 / 201. Professionally, he works full-time writing Python tests for an embedded C++ project while running a side venture creating books and articles. Mike’s experience spans from GUIs to automation and testing, and he is an active voice in the Python community, frequently contributing to Python-centric publications like Real Python.
What to Know If You're New to Python
If you’re just getting started in Python and want to understand this episode’s focus on building GUIs, here are a few essential points:
- Familiarity with basic Python syntax, especially classes and importing libraries, will help you follow the discussion about GUI frameworks.
- Understanding how Python packages and dependencies work (i.e., using
pip install
) is key for getting libraries like wxPython set up. - Having a sense of event-driven programming concepts will make the discussion of widget callbacks and event bubbling clearer.
- Recognizing the Python package distribution story (like using PyInstaller or py2exe) will help you comprehend how to share Python GUIs with non-developers.
Key Points and Takeaways
Why wxPython? wxPython (sometimes pronounced “Wix Python”) is a Python wrapper around the C++ wxWidgets library, which emphasizes native-look-and-feel across operating systems. This means that on Windows, macOS, and Linux, widgets blend in with that platform’s default UI styles. Mike Driscoll highlighted how wxPython’s permissive license, pip installability, and stable API make it an excellent choice for professional desktop apps.
- Links and Tools:
Other GUI Frameworks in Python The episode discussed alternatives like Tkinter, PyQt / PySide, Kivy, PySimpleGUI, and Beware’s Toga. Each has its own philosophy: Tkinter ships with many Python installations (though not always on every OS), PyQt / PySide offer robust tooling with some licensing nuances, Kivy excels in touchscreen and game-like interfaces, PySimpleGUI simplifies adding a quick front-end for scripts, and Toga aims at true native widgets but is still in early development.
- Links and Tools:
Event Handling and Native Dialogs wxPython provides straightforward event binding, allowing you to connect button clicks or menu selections to Python functions. Unlike some frameworks, wxPython uses real native file dialogs (e.g., Finder on macOS, Windows Explorer dialogs) that match a user’s expectations. The event “bubbling” system in wxPython means events can flow up to parent containers if not handled at a lower level.
- Links and Tools:
Designing Layouts with Sizers Layout management in wxPython is driven by sizers—particularly box sizers (vertical or horizontal) and grid sizers. Complex UIs can be created by nesting sizers to handle alignment and resizing behavior, giving you fine-grained control while preserving responsiveness. This approach can become verbose for bigger applications, so wrappers or a visual design tool like wxGlade can help.
- Links and Tools:
Building Real-World Apps (Examples from Mike’s Book) Mike described several reference applications that demonstrate wxPython’s capabilities, including an image viewer leveraging the Pillow library, a database viewer integrating with SQLAlchemy, and an archiver using Python’s tar/zip file modules. He also highlighted an app that pulls images from NASA’s public API, showcasing how wxPython works well with web-driven data.
- Links and Tools:
ObjectListView and Other Custom Widgets For sophisticated data grids, Mike suggested ObjectListView, a wrapper around wx.ListCtrl that streamlines displaying tabular data. wxPython also bundles additional custom widgets in
wx.lib
orwx.agw
—making it easier to handle tasks like advanced tree controls, toggles, and specialized list displays.- Links and Tools:
Prototyping GUIs (Balsamiq and Others) Before writing code, you can sketch your interface ideas with tools such as Balsamiq or even the Qt Designer to visually plan widget placement (though Qt Designer itself outputs Qt code). The big benefit is clarifying your layout and user flow before committing to code, which is especially valuable in large or collaborative projects.
- Links and Tools:
Packaging & Distributing Desktop Apps One of the biggest hurdles for Python GUIs is distributing them without requiring users to install Python or libraries. PyInstaller is a popular cross-platform solution that packages your code, dependencies, and even native libraries into a stand-alone executable. Tools like py2exe (Windows-only) and py2app (macOS-only) are also options. Mike noted that single-file executables might trigger antivirus flags, so you may need signing certificates or alternate packaging approaches in some cases.
- Links and Tools:
Mike’s Writing and Community Engagement Beyond wxPython, Mike actively writes books to fill knowledge gaps for Python beginners and intermediate users. He also contributes articles to Real Python, focusing on topics like PDF generation (ReportLab), data manipulation, and bridging the gap between new features and real-world usage. His passion for teaching was evident throughout the conversation.
- Links:
Incorporating Modern Python Features Modern Python capabilities such as
pathlib
, f-strings, context managers, and type hints can streamline wxPython code. For example, file dialogs can be wrapped in context managers, simplifying your code and making it more readable. Embracing these language improvements helps you keep GUI code Pythonic.
- Tools / Concepts:
- License Clarity and Upgrades wxPython’s licensing model (mostly LGPL-like) is permissive enough for both open source and proprietary apps. This stands in contrast to some frameworks, such as PyQt with a GPL license that requires open sourcing your code unless you acquire a commercial license. Mike highlighted the straightforward nature of upgrading wxPython, especially post–Phoenix release.
Interesting Quotes and Stories
- “The big thing about wxPython is that it does do native widgets wherever possible. It’s really neat when your file dialog looks exactly like your OS expects.”
- “I still do a full-time job with Python, but I also write these books as a hobby-slash-side-job. It’s fun to dive into a new topic and share what I’ve learned.”
- “I realized you can create a UI for NASA’s API, and all of a sudden, you’re browsing photos from space right from your desktop. That’s the beauty of combining wxPython and a neat public API.”
Key Definitions and Terms
- Sizers: Layout managers in wxPython that dynamically position and size widgets.
- Event Bubbling: The process where UI events travel up the widget hierarchy until they are handled.
- ObjectListView: A wrapper around wx.ListCtrl for presenting tabular data with less boilerplate.
- Phoenix: The name for wxPython’s modernization effort to make it Python 3–friendly and pip-installable.
Learning Resources
Below are a few ways to deepen your Python foundation or explore building GUIs:
- Python for Absolute Beginners: Ideal if you need a thorough Python jumpstart.
- Building Data-Driven Web Apps with Flask and SQLAlchemy: Not a desktop GUI, but if you like building apps and want a Python-based approach for the web.
- Getting started with pytest: Master testing your GUI code’s logic with Python’s popular test framework.
Overall Takeaway
Building desktop applications in Python may not be as trendy as web or mobile development, yet wxPython shows that Python can deliver stable, native-look cross-platform solutions. By understanding key concepts like sizers, event handling, and distribution, you can confidently create polished apps for professional or personal use. Mike Driscoll’s enthusiasm for GUIs—combining classical Python knowledge with modern tooling—reminds us that the Python ecosystem offers powerful solutions wherever our creativity leads.
Links from the show
Creating GUI Applications with wxPython book: amazon.com
PySimpleGUI: pysimplegui.readthedocs.io
DearPyGui: github.com
wxPython: wxpython.org
wxPython Phoenix: github.com
wxWidgets: wxwidgets.org
wxFormBuilder: github.com
wxGlade: sourceforge.net
Balsamiq: balsamiq.com
RoboMongo: robomongo.org
Toga: beeware.org
api.nasa.gov: api.nasa.gov
PyInstaller: pyinstaller.org
URLify app: pyinstaller.org
wingware: wingware.com
openpyxl: openpyxl.readthedocs.io
Watch this episode on YouTube: youtube.com
Episode transcripts: talkpython.fm
--- Stay in touch with us ---
Subscribe to Talk Python on YouTube: youtube.com
Talk Python on Bluesky: @talkpython.fm at bsky.app
Talk Python on Mastodon: talkpython
Michael on Bluesky: @mkennedy.codes at bsky.app
Michael on Mastodon: mkennedy