Library Guide

Dear PyGui

High-FPS GPU immediate-mode UI for dashboards, live plots and scientific tools.

GPU immediate-mode Real-time / tools

What Is Dear PyGui?

Dear PyGui is a fast, GPU-accelerated Python GUI framework built on Dear ImGui โ€” the immediate-mode UI library popular in game development and real-time tooling. Instead of retaining widget objects that persist across frames, immediate-mode GUIs rebuild the interface every frame. This sounds wasteful but is extremely efficient for dynamic, data-heavy interfaces that change constantly.

Dear PyGui excels where traditional retained-mode toolkits (tkinter, Qt) struggle: live plots updating at 60 FPS, node editors, debug overlays, and instrument dashboards.

Architecture & Core Concepts

  • Immediate mode โ€” UI code runs every frame inside the render loop.
  • Context โ€” dpg.create_context() initializes; dpg.destroy_context() cleans up.
  • Viewport โ€” the OS window via create_viewport() + show_viewport().
  • Windows & items โ€” dpg.window(), add_button(), add_plot() build the UI tree.
  • Callbacks โ€” callback parameter on widgets; dpg.set_frame_callback() for per-frame logic.
  • GPU rendering โ€” all drawing goes through OpenGL/DirectX for high throughput.

Built-in capabilities

FeatureAPI
Line / scatter plotsdpg.add_plot(), add_line_series()
Node editordpg.add_node_editor()
Tablesdpg.add_table()
File dialogsdpg.add_file_dialog()
Themes & stylingdpg.add_theme(), bind_theme()

Installation

shell
pip install dearpygui

# Requires Python 3.8+ and a GPU with OpenGL support
python -c "import dearpygui.dearpygui as dpg; print('OK')"

Example 1 โ€” Basic window

python
import dearpygui.dearpygui as dpg

dpg.create_context()
with dpg.window(label="Demo"):
    dpg.add_text("Hello from Dear PyGui")
    dpg.add_button(label="Click", callback=lambda: print("hi"))
dpg.create_viewport(title="Dear PyGui demo", width=400, height=200)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

Example 2 โ€” Live updating plot

python
import dearpygui.dearpygui as dpg
import math

dpg.create_context()
with dpg.window(label="Live sine wave"):
    with dpg.plot(label="Plot", height=300, width=500):
        dpg.add_plot_axis(dpg.mvXAxis, label="x")
        y_axis = dpg.add_plot_axis(dpg.mvYAxis, label="y")
        series = dpg.add_line_series([], [], parent=y_axis)

phase = [0.0]
def update():
    phase[0] += 0.05
    xs = [x/10 for x in range(628)]
    ys = [math.sin(x/50 + phase[0]) for x in range(628)]
    dpg.set_value(series, [xs, ys])

dpg.set_frame_callback(1, lambda: dpg.set_frame_callback(dpg.get_frame_count()+1, update) or update())
dpg.create_viewport(title="Plot", width=550, height=400)
dpg.setup_dearpygui(); dpg.show_viewport(); dpg.start_dearpygui(); dpg.destroy_context()

Practical advice

  • Think in frames: UI code that runs every frame should stay lightweight.
  • Use dpg.add_table() for large data grids with sorting and scrolling.
  • Dear PyGui is not ideal for traditional form-based business apps โ€” use Qt or tkinter instead.
  • Combine with NumPy for high-performance plot data without Python loops where possible.
  • The aesthetic is "developer tool" โ€” embrace it or choose CustomTkinter for polish.

Real-world use cases

  • Real-time sensor dashboards and oscilloscope-style displays
  • ML training monitors (loss curves, metrics live)
  • Game engine debug panels and profilers
  • Scientific instrument control interfaces
  • Node-based visual programming editors

โœ“ Strengths

  • Very high performance / FPS
  • Built-in plotting & node editor
  • Great for real-time tools
  • Simple API for dynamic UIs

โœ— Weaknesses

  • Non-native, "tool" aesthetic
  • Younger ecosystem
  • Less suited to classic form apps
  • Immediate-mode paradigm takes adjustment
Use it when

You need live data visualization, instrument panels, or debug overlays that update at high frame rates. Not for traditional desktop applications with menus and forms.