Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Demos & Tutorials

The demos of Dear ImGui Bundle, by category, as in its demo launcher (the “Demo Apps” tab of demo_imgui_bundle, or python -m imgui_bundle.demos_python.demo_immapp_launcher). Most of them run in your browser, in the Python playground; some also exist in C++, in the interactive explorer.

In each card, ▶︎ Run opens the demo in your browser, and Code shows its source, on GitHub.

Dear ImGui Bundle

The bundle at a glance

Welcome to Dear ImGui Bundle

Welcome to Dear ImGui Bundle

Interactive Python & C++ apps for desktop, mobile, and web - powered by Dear ImGui.

Python: ▶︎ Run · Code

Start here

What Dear ImGui Bundle is, in two minutes

What is an Immediate GUI

What is an Immediate GUI

With Dear ImGui, your GUI code is simple and direct: no widget trees, no callbacks, no state synchronization.

More

You call functions to create widgets, and they return the current value. That’s it.

Python: ▶︎ Run · Code

Hello world, in two lines

Hello world, in two lines

ImmApp opens the window, runs the loop, and calls your GUI function at every frame: immapp.run(gui) is all it takes.

More

Add widgets to that function, and you have an app. The C++ version is three lines.

Python: ▶︎ Run · Code
C++: ▶︎ Run · Code

A parametric curve

A parametric curve

Turn the knobs, or click Random: the curve follows at once.

More

At every frame, the GUI function draws the plot with ImPlot and the knobs with imgui-knobs, and reads their values right there. No callbacks, no widget objects: that is the immediate mode.

Python: ▶︎ Run · Code
C++: ▶︎ Run · Code

A plot and markdown, in a few lines

A plot and markdown, in a few lines

A cosine wave moves in an ImPlot plot, under a text written in markdown.

More

Both are add-ons, activated in one call: immapp.run(gui, with_implot=True, with_markdown=True). A good start for a small app.

Python: ▶︎ Run · Code
C++: ▶︎ Run · Code

Assets and add-ons

Assets and add-ons

Load images and icons from your assets folder, and use two add-ons: markdown and ImPlot.

More

A markdown editor with a live preview, and a pie chart whose values you can drag. Tick More info under each part to see how it is done. The add-ons are activated with immapp.AddOnsParams.

Python: ▶︎ Run · Code
C++: ▶︎ Run · Code

Library tours

The libraries in the bundle: full demos and showcases

ImGui full demo

ImGui full demo

Every widget and feature of Dear ImGui, in Python.

More

The reference to learn Dear ImGui by example (a port of imgui_demo.cpp). Browse it next to its code in the Dear ImGui Explorer.

Python: ▶︎ Run · Code

ImPlot full demo

ImPlot full demo

Every kind of plot of ImPlot, in Python: lines, scatter, bars, heatmaps, histograms, real-time plots and more.

More

A port of implot_demo.cpp: browse it next to its code in the Dear ImGui Explorer.

Python: ▶︎ Run · Code

ImPlot3D full demo

ImPlot3D full demo

Rotatable, zoomable 3D plots in Python with ImPlot3D: lines, scatter, surfaces, meshes and more.

More

A port of implot3d_demo.cpp: browse it next to its code in the Dear ImGui Explorer.

Python: ▶︎ Run · Code

ImPlot3D butterfly effect

ImPlot3D butterfly effect

Two trajectories of the Lorenz system start almost at the same point, and soon go completely different ways.

More

This is the butterfly effect, the signature of chaos theory. The plot uses ImPlot3D, which adds rotatable, zoomable 3D plots to Dear ImGui.

Python: ▶︎ Run · Code

ImmVision image inspection

ImmVision image inspection

ImmVision is an image debugger for Dear ImGui with zoom, pan, pixel inspection, and colormaps.

Python: ▶︎ Run · Code

Themes and theme tweaking

Themes and theme tweaking

Pick a complete look for your app, then fine-tune its colors, rounding and spacing.

More

The complete looks come from Hello ImGui.

Python: ▶︎ Run · Code

Build an app

Layouts, docking, backgrounds, fonts, testing: what a real application needs

Resizable panels with child windows

Resizable panels with child windows

Learn how to create resizable adjacent panels, using child windows.

Python: ▶︎ Run · Code

Dockable windows

Dockable windows

Hello ImGui provides a docking system: define named dock spaces, then assign windows to them.

More

Windows can be dragged, tabbed, and rearranged by the user.

Python: ▶︎ Run · Code

A full app: docking, fonts, logs

A full app: docking, fonts, logs

A template for a real application, built with Hello ImGui: copy it and start from there.

More

Dockable windows with several layouts, colored fonts and emojis, a log window, a status bar, toolbars, menus and a theme chooser. Your settings are saved, and restored at the next start. The code is heavily commented.

Python: ▶︎ Run · Code
C++: ▶︎ Run · Code

Custom 3D background (OpenGL)

Custom 3D background (OpenGL)

Draw anything behind your GUI with OpenGL: here, an animated sea whose waves and colors you can tune.

More

The Seascape shader is by Alexander Alekseev (TDM, 2014). Hello ImGui calls runner_params.callbacks.custom_background at each frame, before the GUI: that is where it draws, with OpenGL (PyOpenGL in Python).

Desktop only

Python: Code
C++: ▶︎ Run · Code

Power save when idle

Power save when idle

When nothing happens, Hello ImGui lowers the frame rate to spare the CPU: watch the FPS and the spinner slow down.

More

Move the mouse, and they speed up again. The slider sets fps_idle (0 means full speed), and the checkbox turns idling off, for example during an animation.

Python: ▶︎ Run · Code
C++: ▶︎ Run · Code

Chinese and other non-Latin fonts

Chinese and other non-Latin fonts

The bundled fonts cover Latin, Greek and Cyrillic only: other scripts show up as ???.

More

The fix: load a font that has the glyphs you need, first, so that it becomes the default font. This demo shows how, with Noto Sans SC: download it, and the demo’s sample lines come alive.

Desktop only

Python: Code
C++: ▶︎ Run · Code

Drag and drop

Drag and drop

Drag a name onto another button to copy it, move it, or swap the two: the radio buttons pick the mode.

More

Each button is both a drag source and a drop target. Adapted from the drag and drop section of the Dear ImGui demo.

Python: ▶︎ Run · Code
C++: ▶︎ Run · Code

Command palette

Command palette

A searchable list of commands, as in VS Code: press Ctrl+Shift+P (Cmd+Shift+P on macOS).

More

Type a few letters to filter it. One command changes the theme in two steps, another writes to the log below. Learn how to register commands and their callbacks with imgui-command-palette.

Python: ▶︎ Run · Code
C++: ▶︎ Run · Code

Test engine

Test engine

Three windows: the Dear ImGui demo, the ImGui Test Engine panel, and a few buttons that run tests.

More

Watch a test drive the mouse and the keyboard: it opens tree nodes, clicks buttons, types text, and checks the results. See the test engine doc.

Desktop only

Python: Code
C++: ▶︎ Run · Code

Drive an app, capture screenshots

Drive an app, capture screenshots

A test function drives the app: it clicks, moves a slider, opens a header, and takes a screenshot at each step.

More

immapp.testing.run() starts the app, runs the test function, then exits. Handy for automated checks and for documentation pictures. See the test engine doc.

Desktop only

Python: Code
C++: ▶︎ Run · Code

Lessons and explorables

Interactive scientific demos built with Dear ImGui Bundle, showcasing its capabilities

Interactive exploration of the Mandelbrot set

Interactive exploration of the Mandelbrot set

Click a point of the Mandelbrot set to see its Julia set.

More

Fly to famous values of c, and zoom into both pictures: near each point, the two sets look alike.

Python: ▶︎ Run · Code

A tiny neural network learns two spirals

A tiny neural network learns two spirals

Can 16 neurons tell two spirals apart? Watch a tiny neural network learn, live, as in the TensorFlow Playground.

More

Then read how it works, formula by formula, next to its numpy code.

Python: ▶︎ Run · Code

Simple harmonic motion

Simple harmonic motion

A mass on a spring, a pendulum, a vibrating string: they all follow the same equation.

More

It is the equation of simple harmonic motion (for the pendulum, at small angles). Adjust the mass and the spring stiffness, and watch how the motion changes.

Python: ▶︎ Run · Code

Double pendulum

Double pendulum

A double pendulum is a chaotic system: tiny changes in its initial conditions lead to wildly different trajectories.

More

Drag the angles to set initial positions, then release and watch chaos unfold.

Python: ▶︎ Run · Code

Fourier epicycles

Fourier epicycles

Any closed curve can be approximated by a sum of rotating circles (a Fourier series).

More

Adjust the number of circles to see how the approximation improves.

Python: ▶︎ Run · Code

Boids (flocks)

Boids (flocks)

A flock of birds emerges from three simple local rules, with no leader and no plan.

More

Each bird stays apart from its neighbors (separation), flies their way (alignment), and stays with them (cohesion). This is the boids model of Craig Reynolds (1986).

Python: ▶︎ Run · Code

Logistic map

Logistic map

A very simple equation, and yet it can lead to wildly different behaviors, up to chaos.

More

The logistic map, x(n+1) = r * x(n) * (1 - x(n)), models for example the growth of a population with limited resources. Depending on r, it is stable, periodic (in 2-cycles, 4-cycles, etc), or chaotic. Let’s explore this.

Python: ▶︎ Run · Code

Python specifics

Async, matplotlib, pydantic, context managers, and pure Python backends

Context managers (imgui_ctx)

Context managers (imgui_ctx)

In Python, with imgui_ctx.begin("Window"): replaces a begin() / end() pair, and the end() can no longer be forgotten.

More

The same exists for child windows, menus, popups, tables, tabs, fonts and styles, and for ImPlot with implot_ctx. Open a section to try it and read its code. See the Python tips.

Python: ▶︎ Run · Code

Run code alongside the GUI (async)

Run code alongside the GUI (async)

The GUI runs as an asyncio task, while a Python loop keeps computing.

More

The window shows both rates: the GUI’s frames per second, and the loop’s computations per second. The loop yields with await asyncio.sleep(0) to share the event loop. See async support.

Desktop only

Python: Code

Control the GLFW window

Control the GLFW window

glfw_utils.glfw_window_hello_imgui() returns the GLFW window that Hello ImGui created.

More

With it, any function of pyGLFW works on your app’s window. Here, buttons maximize, restore, minimize or center it, a slider sets its opacity, and another button makes it ask for attention in the taskbar.

Desktop only

Python: Code

Matplotlib figures

Matplotlib figures

imgui_fig.fig() shows a Matplotlib figure as an image in the GUI.

More

On the left, an animated sine wave, redrawn at each frame, with a slider for its amplitude. On the right, a static figure, drawn once. Handy to reuse existing Matplotlib code; for fast interactive plots, prefer ImPlot.

Python: ▶︎ Run · Code

Pydantic models

Pydantic models

Save and load your app’s settings with Pydantic, ImVec2 and colors included.

More

ImVec2_Pydantic, ImVec4_Pydantic and ImColor_Pydantic are the usual ImVec2, ImVec4 and ImColor, usable as fields of a Pydantic model. The demo shows such a model, turns it into JSON, validates it back, and checks that nothing was lost.

Python: ▶︎ Run · Code

Python backend: GLFW

Add ImGui to your own GLFW app: you write the app loop, and a Python backend does the rest.

More

The backend passes the inputs to ImGui and draws it with PyOpenGL. Shows the ImGui demo, and a window with markdown and a formula. Needs pip install imgui-bundle[glfw,opengl].

Desktop only

Python: Code

Python backend: SDL2

Add ImGui to your own SDL2 app: you write the event loop, and a Python backend does the rest.

More

It uses PySDL2; the backend passes the events to ImGui and draws it with PyOpenGL. Shows the ImGui demo, and a window with markdown and a formula. Needs pip install imgui-bundle[sdl2,opengl] pysdl2-dll.

Desktop only

Python: Code

Python backend: SDL3

Add ImGui to your own SDL3 app: you write the event loop, and a Python backend does the rest.

More

It uses PySDL3; the backend passes the events to ImGui and draws it with PyOpenGL. Shows the ImGui demo, and a window with markdown and a formula. Needs pip install imgui-bundle[sdl3,opengl].

Desktop only

Python: Code

Python backend: pyglet

Add ImGui to your own pyglet app or game: pyglet runs the loop, and a Python backend does the rest.

More

The backend passes pyglet’s events to ImGui and draws it with PyOpenGL. Shows the ImGui demo, and a window with markdown and a formula. Needs pip install imgui-bundle[pyglet,opengl].

Desktop only

Python: Code

Python backend: pygame

Add ImGui to your own pygame game: you write the game loop, and a Python backend does the rest.

More

The backend passes pygame’s events to ImGui and draws it with PyOpenGL. Shows a window with markdown, a formula and a few widgets. Needs pip install imgui-bundle[opengl] pygame.

Desktop only

Python: Code

Python backend: wgpu

ImGui drawn with WebGPU, by the ImGui renderer of wgpu-py, in a rendercanvas window.

More

wgpu-py uses Dear ImGui Bundle for its GUIs. Shows the ImGui demo, and a window with markdown and a formula. Needs pip install imgui-bundle[wgpu].

Desktop only

Python: Code

In the browser

Deploy to the web, and use the browser’s WebGL and WebAudio from Python

Minimal HTML page

Minimal HTML page

Dear ImGui Bundle apps can run entirely in the browser using Pyodide.

More

The HTML file below is a complete, self-contained app in about 80 lines - no server, no build step.

Python: ▶︎ Run · Code

WebGL shader as background

WebGL shader as background

The Mandelbrot set, drawn by a fragment shader behind the GUI.

More

Pyodide only: this demo calls the browser’s WebGL2 API directly, through Python’s js interop. On desktop, you would use PyOpenGL instead.

Browser only

Python: ▶︎ Run · Code

WebGL / OpenGL custom background

WebGL / OpenGL custom background

One source file, two platforms: a shader behind the GUI, with OpenGL on desktop and WebGL in the browser.

More

The shader is the famous “Seascape” from Shadertoy, by Alexander Alekseev. In the browser, the app runs with Pyodide.

Python: ▶︎ Run · Code

WebGL 3D cube rendered to a texture

WebGL 3D cube rendered to a texture

A 3D cube drawn with WebGL2 into a texture, and shown in the GUI by imgui.image().

More

No copy between the GPU and the CPU at each frame.

Browser only

Python: ▶︎ Run · Code

WebAudio synthesizer

WebAudio synthesizer

A small synthesizer written in Python: play the piano with the mouse or the computer keyboard, or let it play a tune.

More

Pick a waveform, add some echo, and watch the scope. Pyodide only: it plays through the browser’s WebAudio API, via Pyodide’s js interop.

Browser only

Python: ▶︎ Run · Code

Haikus

Tiny programs, big effect

A beating heart

A beating heart

A heart curve drawn with ImPlot beats at the rate set by a knob from imgui-knobs.

More

A few lines of Python: a parametric curve, scaled by a pulse at each frame. Turn the knobs to change the heart rate, or its thickness.

Python: ▶︎ Run · Code
C++: ▶︎ Run · Code

Butterfly effect, in a few lines

Butterfly effect, in a few lines

Two trajectories of the Lorenz system start almost at the same point, then drift apart: chaos in action.

More

Drawn in 3D with ImPlot3D. Sliders change the system’s parameters and the gap between the two starting points; Reset starts them over.

Python: ▶︎ Run · Code
C++: ▶︎ Run · Code