Dear PyGui: Simple yet Fast Python GUI Apps
Dear PyGui: A fast and powerful Graphical User Interface Toolkit for Python with minimal dependencies, created by Jonathan Hoffstadt and Preston Cothren. They are here to tell us all about it.
Episode Deep Dive
Guests Introduction and Background
Jonathan Hoffstadt and Preston Cothren both come from mechanical engineering backgrounds, where they frequently use computational and simulation tools. They developed an early passion for programming in C++ and Python and discovered that Python was ideal for quickly automating mechanical engineering workflows while also offering the potential for interactive GUIs. As they built and refined tools for engineering tasks, they found existing Python UI frameworks limiting, leading them to create Dear PyGui, an immediate-mode style GUI library that prioritizes simplicity, performance, and a lower barrier to entry for both beginners and advanced Python users.
What to Know If You’re New to Python
If you’re newer to Python and want to fully appreciate how Dear PyGui fits into the Python ecosystem, here are a few handy tips:
- Python comes with a simple built-in GUI library called
tkinter
, but it can be limiting for more dynamic or real-time applications. - Python’s syntax is intuitive, making it a good choice for rapid prototyping, especially in fields like engineering or data science.
- Dear PyGui uses Python on top but is powered underneath by C++ and graphics APIs (like DirectX, Metal, or OpenGL), so you can leverage Python’s ease of use while accessing powerful performance.
Key Points and Takeaways
- Dear PyGui’s Immediate-Mode Approach
Dear PyGui is built on top of the immediate-mode paradigm (inspired by ImGui in C++). Instead of having widgets permanently “retained,” the UI is redrawn every frame, which makes real-time updates more fluid and requires less boilerplate code to keep data in sync. This design is particularly attractive for applications that need frequent or large UI updates, such as live dashboards or dynamic editors.
- Links and Tools:
- Origins in Mechanical Engineering Jonathan and Preston initially faced challenges in automating mechanical engineering workflows, especially in areas like stress analysis and fluid simulation. When confronted with high software-licensing costs for tools like MATLAB (and even occasional Fortran coding for advanced engineering apps!), Python offered a free, more flexible alternative. Dear PyGui emerged from their need to build user-friendly, modern UI dashboards and tools quickly for tasks like visualizing FEA data or controlling robotics setups.
- Real-Time Visualization and Plotting
Dear PyGui integrates an advanced plotting library (ImPlot) for real-time data visualization. By leveraging the immediate-mode model, you can easily produce live-updating graphs, dynamic charts, or candlestick plots without manually managing redrawing or callbacks. This is useful not only in mechanical engineering but also for live dashboards—such as tracking cryptocurrency data, simulation outcomes, or scientific experimentation.
- Links and Tools:
- Flexible Node Editor A standout feature of Dear PyGui is its customizable node editor. You can create nodes that house various widgets—like inputs, plots, or text—then connect them to visualize data flows or even build data pipelines in real time. This is especially useful for prototyping complex workflows, where dragging lines between components in a visual environment can give a more intuitive feel than writing code for each connection.
- Built-In Debugging and Developer Tools
Dear PyGui includes item registries, texture registries, and in-app inspectors that let developers view and debug UI elements at runtime. With a single command (e.g.,
show_item_registry()
), you get insight into widget hierarchies, states (hovered or active), and resource usage. These built-in tools make it easier to prototype and refine your application’s UI. - Cross-Platform Rendering and Planned Vulkan Support
On Windows, Dear PyGui uses DirectX 11; on macOS, it uses Metal; on Linux, it uses OpenGL by default. However, the project is steering toward an all-Vulkan backend for cross-platform uniformity and more direct GPU access. While this approach entails deeper complexity under the hood, developers using Dear PyGui still enjoy a consistent Pythonic interface without having to learn the underlying graphics APIs.
- Tools and APIs:
- DirectX, Metal, OpenGL, Vulkan (future)
- Tools and APIs:
- Distribution and Packaging
For distributing applications to end users, developers can bundle Dear PyGui-based apps into a single executable using tools like PyInstaller. The conversation highlights the general pain point of Python distribution, especially for non-technical audiences. Although bundling involves extra steps, it enables sharing your GUI apps without requiring users to install Python separately or worry about dependencies.
- Links and Tools:
- Minimal Dependencies, High Performance A goal of Dear PyGui is to stay lightweight, using as few external Python packages as possible. The real performance magic happens behind the scenes in compiled C++ code, enabling smooth 60+ frames-per-second rendering. This combination lets Python developers quickly script their ideas without sacrificing speed for interactive UIs or 2D/3D previews.
- Mechanical Engineering Meets Python The guests touched on how mechanical engineers often rely on heavy, proprietary software with large license fees (MATLAB, various FEA packages). Python solutions like Dear PyGui offer a low-cost (often free) and open ecosystem for building specialized UIs or engineering utilities. This approach helps integrate deep engineering calculations with user-friendly interfaces for less-technical colleagues.
- Community and Support Dear PyGui’s developers emphasize community engagement through tools like Discord, GitHub discussions, and thorough demos. The library’s demo app showcases almost every feature, making it an excellent starting point for learning. Contributors, documentation writers, and sponsor support all help push the library forward, especially since it’s a side project for Jonathan and Preston.
Interesting Quotes and Stories
- “Selling to developers isn’t easy.” Jonathan described the initial commercial path they tried with Engineer Sandbox. They realized that developers—accustomed to open-source—are hesitant to pay for libraries, hence their move to open-source with Dear PyGui.
- “They are truly the same data.” One of Dear PyGui’s distinctive features is that multiple UI widgets can share the exact same underlying value, removing the need for complex callback synchronization.
- “I was just jealous. MATLAB is not that amazing, but it's better than Fortran.” A humorous moment contrasting older engineering languages (like Fortran) with more modern, flexible languages like Python.
Key Definitions and Terms
- Immediate-Mode GUI: A style of creating user interfaces that draws all elements each frame rather than storing widget states in a retained tree. It’s popular in game development and real-time apps (e.g., ImGui).
- Retained-Mode GUI: A more traditional approach where widgets remain in memory and have persistent states. Most classic GUI frameworks (e.g., Tkinter, PyQt) follow this model.
- Viewport: The main application window that hosts the internal, “floating” Dear PyGui windows.
- Vulkan: A low-overhead, cross-platform 3D graphics and compute API that gives developers more explicit control over GPU operations compared to older APIs like OpenGL or DirectX 11.
Learning Resources
Below are some resources to learn more and go deeper into Python and GUIs.
- Python for Absolute Beginners: A comprehensive introduction to Python programming if you’re just getting started or need a solid refresher.
- Dear PyGui Documentation: The official Wiki for installation guides, demos, and advanced topics.
- PyInstaller: Popular tool for packaging Python apps into stand-alone executables.
- ImPlot GitHub: For advanced and interactive plotting inside your Dear PyGui apps.
Overall Takeaway
Dear PyGui represents a refreshing direction for Python-based GUIs by bringing the immediacy and responsiveness typically found in game-development UI libraries. Jonathan and Preston’s engineering background drove them to create a high-performance but minimalistic UI framework that feels right at home in the Python ecosystem. Whether you need quick prototypes or sophisticated real-time dashboards, Dear PyGui’s immediate-mode architecture offers both power and simplicity—making it a compelling choice for Python developers seeking modern, snappy interfaces without the usual overhead of more traditional GUI toolkits.
Links from the show
Preston Cothren: @toulaboy3
Dear PyGUI source: github.com
Video tutorials: dearpygui.readthedocs.io
Getting started tutorial: dearpygui.readthedocs.io
OpenFOAM: openfoam.org
Vulkan: vulkan.org
Michael's Python Shorts video series
The playlist: talkpython.fm/python-shorts
Michael's YouTube Channel: youtube.com
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