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.

Hello ImGui

Hello ImGui: the app runner. It creates the window and the rendering backend, and runs the loop, on desktop, mobile and the web.

Around Dear ImGui, it adds what an app needs: dockable windows and layouts, a menu and a status bar, fonts and icons, assets, DPI awareness, themes, power saving when idle, and the user’s settings.

Start with hello_imgui.run(gui_function); for more control, fill a RunnerParams. immapp.run does the same, and also sets up the add-ons (ImPlot, markdown, the node editor...): most apps of the bundle use it. Docs: https://pthom.github.io/hello_imgui/book/

Upstream repository · The book’s page

Modules

In imgui_bundle (from imgui_bundle import hello_imgui):

Demos using it

The demos of the catalog that use it (the pictures link to their code and to the playground).

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.

Uses: ImPlot

Python: ▶︎ Run · Code
C++: ▶︎ 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
C++: ▶︎ 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

Power save when idle

Power save when idle

When nothing happens, Hello ImGui lowers the frame rate to spare the CPU: after 3 seconds, the live plot and the spinner become choppy.

More

Content that changes on its own says so with hello_imgui.set_item_is_live(), and keeps the full speed while it is visible. The idling settings are global.

Uses: ImPlot, toggles, spinners

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. This demo shows two ways, with Noto Sans SC:

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), or its button.

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.

Uses: command palette

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

Test engine

Test engine

Watch a ImGui Test Engine drive the mouse and the keyboard: it clicks buttons, types text, etc., and checks the results.

More

For scripted runs on top of it (automated tests, pictures, an AI agent at the mouse), see the immapp.testing demo. See the test engine doc.

Python: ▶︎ Run · Code
C++: ▶︎ 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

Log window

Log window

A log window for your app, with four levels: debug, info, warning and error.

More

Call hello_imgui.log() anywhere, and show the window with hello_imgui.log_gui(). Its colors follow the theme. Adapted from ImGuiAl.

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

Async: compute beside the GUI

Async: compute beside the GUI

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 works in short slices, and yields between them with await asyncio.sleep(...) to share the event loop. See async support.

Python: ▶︎ Run · Code

3D sea in OpenGL (desktop)

3D sea in OpenGL (desktop)

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

Uses: OpenGL

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