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.

ImGui Knobs

ImGui Knobs: rotary knobs for numeric values, in several styles (tick, dot, wiper, stepped, space...).

knob(label, value, v_min, v_max) returns (changed, new_value); knob_int() is its integer version.

Upstream repository · The book’s page

Modules

In imgui_bundle (from imgui_bundle import imgui_knobs):

Demos using it

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

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.

Uses: ImPlot, knobs

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

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.

Uses: ImPlot, knobs

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

Rotor run-up monitor: vibration analysis

Rotor run-up monitor: vibration analysis

A simulated three-axis accelerometer sits on the bearing housing of a rotor whose speed sweeps up and down.

More

The dashboard shows what a vibration analyst would watch:

Uses: ImPlot, knobs, toggles, node editor

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.

Uses: ImPlot, knobs

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.

Uses: ImPlot, knobs, toggles

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.

Uses: ImPlot, knobs, toggles

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).

Uses: ImPlot, knobs, toggles

Python: ▶︎ Run · Code

Medical imaging: a chest CT, its windows, a segmentation

Medical imaging: a chest CT, its windows, a segmentation

A real chest CT, explored as a radiologist would: its slices, its windows, and a region grown from a click.

More

Choose a window preset or drag its bounds on the histogram. Click a structure: the region grows across the slices, and the app measures it and shows it in 3D. A second tab finds the blood vessels of a retina. For research and teaching, not for diagnosis.

Uses: ImPlot, ImPlot3D, ImmVision, knobs, ImGuiKit, OpenCV

Python: ▶︎ Run · Code

Gravitational lensing: a ring, arcs, the Einstein Cross

Gravitational lensing: a ring, arcs, the Einstein Cross

A mass in the foreground bends the light of a galaxy behind it.

More

The left sky shows the galaxy as it is, the right one what we see through the lens. Drag the galaxy (yellow) and the lens (blue), turn the knobs, or start from a preset: an Einstein ring, two images, a giant arc, the Einstein Cross. The thin lines are the critical curve, where the magnification diverges, and its map in the source plane, the caustic: as the galaxy crosses it, images are born or merge. Hover a pixel of the observed sky to see where its light comes from.

Uses: ImPlot, knobs, toggles

Python: ▶︎ Run · Code

Knobs, toggles, spinners and more

Knobs, toggles, spinners and more

Knobs, toggle switches, spinners, a command palette, a dock-like cool bar: widgets beyond Dear ImGui’s own.

More

They come from the libraries in the bundle: imgui-knobs, imgui_toggle, imspinner, imgui-command-palette and ImCoolBar. Also file dialogs: the native ones (portable-file-dialogs), and ImFileDialog, drawn with ImGui.

Uses: knobs, toggles, spinners, cool bar, command palette, file dialogs

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

Uses: knobs, browser APIs

Python: ▶︎ Run · Code