Appearance
Typing
Slimgui has been developed with the following goals in mind:
- Support typing through
.pyifiles to enable good IDE support such as auto-complete, type checking, and docstrings. - Closely match the Dear ImGui API but adapt for Python as necessary. Don't invent new API concepts.
The Slimgui API is similar to pyimgui except somewhat modernized:
- Enums in ImGui are exposed as typed Python enums using
enum.IntEnumandenum.IntFlagto make it clear which API functions consume what type of enums. - Vector types such as
ImVec2,ImVec4, andfloat*arrays are converted to Python tuples such astuple[float, float]forImVec2andtuple[float, float, float, float]forImVec4. - Mutable bool args such as
bool* p_openare input as normalboolvalues and returned as the second element of a 2-tuple. For example,bool ImGui::Checkbox(const char* label, bool* v)is translated todef checkbox(label: str, v: bool) -> tuple[bool, bool], where the first element is the boolean return value ofImGui::Checkbox()and the second element is the new checkbox state.
Public and Internal Types
Typical usage imports the public modules:
python
from slimgui import imgui
from slimgui import implotThe underlying bindings live under slimgui.slimgui_ext.imgui and slimgui.slimgui_ext.implot.
Those slimgui_ext.* modules exist because they expose the native binding layer directly. The public slimgui.imgui and slimgui.implot modules then build on top of that layer by:
- re-exporting many enums and binding types
- adding some higher-level Python wrapper types
For example, some API signatures use wrapper types such as:
slimgui.imgui.WrappedContextslimgui.implot.WrappedContextslimgui.imgui.DrawList
These are distinct from the lower-level types in slimgui.slimgui_ext.*, even when they are related internally.