Introduction
About Dear ImGui Bundle
Dear ImGui Bundle is a bundle for Dear ImGui, including various powerful libraries from its ecosystem. It enables to easily create ImGui applications in C++ and Python, under Windows, macOS, and Linux. It is aimed at application developers, researchers, and beginner developers who want to quickly get started.
Interactive manual & demo in one click!
Click on the animated demonstration below to launch the fully interactive demonstration.
Tip
|
This demonstration is also an interactive manual, similar to the online ImGui Manual |
Batteries included
Dear ImGui Bundle includes the following libraries, which are available in C++ and in Python:
Dear ImGui : Bloat-free Graphical User interface for C++ with minimal dependencies |
|
ImGui Test Engine: Dear ImGui Tests & Automation Engine |
|
Hello ImGui: cross-platform Gui apps with the simplicity of a "Hello World" app |
|
ImPlot: Immediate Mode Plotting |
|
ImGuizmo: Immediate mode 3D gizmo for scene editing and other controls based on Dear ImGui |
|
ImGuiColorTextEdit: Colorizing text editor for ImGui |
|
imgui-node-editor: Node Editor built using Dear ImGui |
|
imgui_md: Markdown renderer for Dear ImGui using MD4C parser |
|
ImmVision: Immediate image debugger and insights |
|
imgui_tex_inspect: A texture inspector tool for Dear ImGui |
|
ImFileDialog: A file dialog library for Dear ImGui |
|
portable-file-dialogs OS native file dialogs library (C++11, single-header) |
|
imgui-knobs: Knobs widgets for ImGui |
|
imspinner: Set of nice spinners for imgui |
|
imgui_toggle: A toggle switch widget for Dear ImGui |
|
ImCoolBar: A Cool bar for Dear ImGui |
|
imgui-command-palette: A Sublime Text or VSCode style command palette in ImGui |
A big thank you to their authors for their awesome work!
Easily port your code between python and C++
The python bindings are autogenerated via an advanced generator (so that keeping them up to date is easy), and closely mirror the original C++ API, with fully typed bindings.
The original code documentation is meticulously kept inside the python stubs. See for example the documentation for imgui , implot, and hello imgui
Thanks to this, code completion in your favorite python IDE works like a charm, and porting code between Python and C++ becomes easy.
Tip
|
GPT can help you translate between C++ and Python: see this conversation where GPT4 was used to translate code and summarize the differences between the C++ and Python APIs. |
Click to see an example
Python
import time
import numpy as np
from imgui_bundle import implot, imgui_knobs, imgui, immapp, hello_imgui
# Fill x and y whose plot is a heart
vals = np.arange(0, np.pi * 2, 0.01)
x = np.power(np.sin(vals), 3) * 16
y = 13 * np.cos(vals) - 5 * np.cos(2 * vals) - 2 * np.cos(3 * vals) - np.cos(4 * vals)
# Heart pulse rate and time tracking
phase = 0
t0 = time.time() + 0.2
heart_pulse_rate = 80
def gui():
global heart_pulse_rate, phase, t0, x, y
# Make sure that the animation is smooth
hello_imgui.get_runner_params().fps_idling.enable_idling = False
t = time.time()
phase += (t - t0) * heart_pulse_rate / (np.pi * 2)
k = 0.8 + 0.1 * np.cos(phase)
t0 = t
imgui.text("Bloat free code")
implot.begin_plot("Heart", immapp.em_to_vec2(21, 21))
implot.plot_line("", x * k, y * k)
implot.end_plot()
_, heart_pulse_rate = imgui_knobs.knob("Pulse", heart_pulse_rate, 30, 180)
if __name__ == "__main__":
immapp.run(gui, window_size=(300, 450), window_title="Hello!", with_implot=True, fps_idle=0) # type: ignore
C++
#include "imgui.h"
#include "implot/implot.h"
#include "imgui-knobs/imgui-knobs.h"
#include "immapp/immapp.h"
#include <cmath>
std::vector<double> VectorTimesK(const std::vector<double>& values, double k)
{
std::vector<double> r(values.size(), 0.);
for (size_t i = 0; i < values.size(); ++i)
r[i] = k * values[i];
return r;
}
int main(int , char *[]) {
// Fill x and y whose plot is a heart
double pi = 3.1415926535;
std::vector<double> x, y; {
for (double t = 0.; t < pi * 2.; t += 0.01) {
x.push_back(pow(sin(t), 3.) * 16.);
y.push_back(13. * cos(t) - 5 * cos(2. * t) - 2 * cos(3. * t) - cos(4. * t));
}
}
// Heart pulse rate and time tracking
double phase = 0., t0 = ImmApp::ClockSeconds() + 0.2;
float heart_pulse_rate = 80.;
auto gui = [&]() {
// Make sure that the animation is smooth
HelloImGui::GetRunnerParams()->fpsIdling.enableIdling = false;
double t = ImmApp::ClockSeconds();
phase += (t - t0) * (double)heart_pulse_rate / (pi * 2.);
double k = 0.8 + 0.1 * cos(phase);
t0 = t;
ImGui::Text("Bloat free code");
auto xk = VectorTimesK(x, k), yk = VectorTimesK(y, k);
ImPlot::BeginPlot("Heart", ImmApp::EmToVec2(21, 21));
ImPlot::PlotLine("", xk.data(), yk.data(), (int)xk.size());
ImPlot::EndPlot();
ImGuiKnobs::Knob("Pulse", &heart_pulse_rate, 30., 180.);
};
ImmApp::Run(
gui, "Hello!",
/*windowSizeAuto=*/false , /*windowRestorePreviousGeometry==*/false, /*windowSize=*/{300, 450},
/*fpsIdle=*/ 25.f, /*withImplot=*/true);
return 0;
}