3. Python imgui reference

From MXWendler Wiki
Jump to navigation Jump to search


Here are listed the commands available in module mxw_imgui, MXWendler's Python binding of Dear ImGui. This is how plugins draw their settings panel, in the onRenderPanel() hook (see the Python Plugin Howto).

mxw_imgui mirrors the Dear ImGui C++ API almost function-for-function: the C++ ImGui::PascalCase names become Python snake_case, one argument at a time. If you already know Dear ImGui (or its C++/other-language bindings), the name of a call is usually a mechanical translation away.

Legend

Everything from the Python Reference Legend applies (floats, integers, strings, OR for alternative formats). In addition:

Dear ImGui widgets that take a pointer to their value in C++ (so the value can be written back) instead return a tuple (changed, value) in Python: changed is true when the user edited the widget this frame, value is the (possibly new) value to keep and pass back in next frame. E.g.:

changed, value = mxw_imgui.slider_float("Speed", value, 0.0, 1.0)

Widgets with several packed floats/ints (drag_float2, slider_int4, ...) take and return a plain Python list/tuple of that length instead of a C array.

Flags (ImGuiTreeNodeFlags, ImGuiWindowFlags, ImGuiCol, ...) are not exposed as named Python constants — pass the plain integer value of the Dear ImGui enum (default 0 means "no flags" for nearly every call). Consult the Dear ImGui headers/docs for the numeric values if you need non-default flags.

Parameters shown as = value in the tables below are optional with that default; omit them to use the default.

Plugins draw into an existing panel — there is no begin/end for top-level windows; start directly with widget calls.

Data types

PYTHON TYPE DESCRIPTION EXAMPLE
mxw_imgui.Vec2() OR mxw_imgui.Vec2(x, y) 2D float vector (.x, .y), used for sizes and positions size = mxw_imgui.Vec2(200, 0)
mxw_imgui.Vec4() OR mxw_imgui.Vec4(x, y, z, w) 4D float vector (.x, .y, .z, .w), used for colors (RGBA) and rectangles col = mxw_imgui.Vec4(1.0, 0.0, 0.0, 1.0)
mxw_imgui.Vector_char, Vector_float, Vector_unsignedchar, Vector_unsignedshort, Vector_DrawCmd, Vector_DrawVert, Vector_FontGlyph Read-only iterable wrappers around Dear ImGui's internal ImVector<T> buffers, returned by some getters (e.g. draw list data). Support len(), iteration and indexing for glyph in font.Glyphs: pass

Style & Fonts

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.push_font(font) push a font onto the font stack for subsequent widgets mxw_imgui.push_font(mxw_imgui.get_font())
mxw_imgui.pop_font() pop the last pushed font mxw_imgui.pop_font()
mxw_imgui.push_style_color(idx, col) push a style color override (col as packed u32 OR Vec4) mxw_imgui.push_style_color(0, mxw_imgui.Vec4(1,0,0,1))
mxw_imgui.pop_style_color(count = 1) pop count previously pushed style colors mxw_imgui.pop_style_color()
mxw_imgui.push_style_var(idx, val) push a style var override (val as float OR Vec2) mxw_imgui.push_style_var(0, 4.0)
mxw_imgui.pop_style_var(count = 1) pop count previously pushed style vars mxw_imgui.pop_style_var()
mxw_imgui.push_allow_keyboard_focus(allow_keyboard_focus) allow/disallow tab-focusing the next widgets mxw_imgui.push_allow_keyboard_focus(false)
mxw_imgui.pop_allow_keyboard_focus() pop the keyboard-focus override mxw_imgui.pop_allow_keyboard_focus()
mxw_imgui.push_button_repeat(repeat) make subsequent buttons behave as repeating (held = repeated clicks) mxw_imgui.push_button_repeat(true)
mxw_imgui.pop_button_repeat() pop the button-repeat override mxw_imgui.pop_button_repeat()
mxw_imgui.get_font() returns the current font object f = mxw_imgui.get_font()
mxw_imgui.get_font_size() returns the current font size in px sz = mxw_imgui.get_font_size()
mxw_imgui.get_font_tex_uv_white_pixel() returns UV coordinate of a white pixel in the font texture, for custom draw-list use uv = mxw_imgui.get_font_tex_uv_white_pixel()
mxw_imgui.get_color_u32(idx, alpha_mul = 1.0) OR mxw_imgui.get_color_u32(col) resolve a style color index, a Vec4, or a packed u32 to a final packed u32 color c = mxw_imgui.get_color_u32(0)
mxw_imgui.get_style_color_vec4(idx) returns the raw Vec4 for a style color index c = mxw_imgui.get_style_color_vec4(0)
mxw_imgui.get_style_color_name(idx) returns the readable name of a style color index mxw_imgui.print_console(mxw_imgui.get_style_color_name(0))
mxw_imgui.set_color_edit_options(flags) set default flags for every subsequent color_edit/color_picker call mxw_imgui.set_color_edit_options(0)

Cursor & Layout

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.push_item_width(item_width) push a fixed width (px, or negative = right-aligned) for subsequent widgets mxw_imgui.push_item_width(150)
mxw_imgui.pop_item_width() pop the pushed item width mxw_imgui.pop_item_width()
mxw_imgui.set_next_item_width(item_width) set the width of just the next widget mxw_imgui.set_next_item_width(300)
mxw_imgui.calc_item_width() returns the width the next widget would use w = mxw_imgui.calc_item_width()
mxw_imgui.push_text_wrap_pos(wrap_local_pos_x = 0.0) push a word-wrap position (0 = wrap at window edge) for subsequent text mxw_imgui.push_text_wrap_pos()
mxw_imgui.pop_text_wrap_pos() pop the pushed wrap position mxw_imgui.pop_text_wrap_pos()
mxw_imgui.separator() draw a thin horizontal separator line mxw_imgui.separator()
mxw_imgui.same_line(offset_from_start_x = 0.0, spacing = -1.0) keep the next widget on the same line as the previous one mxw_imgui.same_line()
mxw_imgui.new_line() force a following widget to start on a new line mxw_imgui.new_line()
mxw_imgui.spacing() add vertical spacing mxw_imgui.spacing()
mxw_imgui.dummy(size) reserve an empty invisible size (Vec2) area, e.g. as a spacer mxw_imgui.dummy(mxw_imgui.Vec2(0, 10))
mxw_imgui.indent(indent_w = 0.0) move the cursor right (indent) mxw_imgui.indent()
mxw_imgui.unindent(indent_w = 0.0) move the cursor back left (unindent), matching a prior indent() mxw_imgui.unindent()
mxw_imgui.begin_group() start a layout group (following widgets are treated as one unit for layout purposes) mxw_imgui.begin_group()
mxw_imgui.end_group() close the current layout group mxw_imgui.end_group()
mxw_imgui.get_cursor_pos() returns the cursor position (Vec2) relative to the current window p = mxw_imgui.get_cursor_pos()
mxw_imgui.get_cursor_pos_x() OR mxw_imgui.get_cursor_pos_y() returns just the X or Y cursor coordinate x = mxw_imgui.get_cursor_pos_x()
mxw_imgui.set_cursor_pos(local_pos) set the cursor position (Vec2), window-relative mxw_imgui.set_cursor_pos(mxw_imgui.Vec2(0, 0))
mxw_imgui.set_cursor_pos_x(local_x) OR mxw_imgui.set_cursor_pos_y(local_y) set just the X or Y cursor coordinate mxw_imgui.set_cursor_pos_x(20)
mxw_imgui.get_cursor_start_pos() returns the initial cursor position of the current window/child p = mxw_imgui.get_cursor_start_pos()
mxw_imgui.get_cursor_screen_pos() returns the cursor position in absolute screen coordinates p = mxw_imgui.get_cursor_screen_pos()
mxw_imgui.set_cursor_screen_pos(pos) set the cursor in absolute screen coordinates mxw_imgui.set_cursor_screen_pos(p)
mxw_imgui.align_text_to_frame_padding() vertically align following text with standard framed widgets on the same line mxw_imgui.align_text_to_frame_padding()
mxw_imgui.get_text_line_height() OR mxw_imgui.get_text_line_height_with_spacing() returns one text line's height, with or without inter-line spacing h = mxw_imgui.get_text_line_height()
mxw_imgui.get_frame_height() OR mxw_imgui.get_frame_height_with_spacing() returns a standard framed widget's height, with or without spacing h = mxw_imgui.get_frame_height()

ID stack

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.push_id(str_id) OR mxw_imgui.push_id(str_id_begin, str_id_end) OR mxw_imgui.push_id(ptr_id) OR mxw_imgui.push_id(int_id) push a scope onto the ID stack, so same-labelled widgets in a loop don't collide mxw_imgui.push_id(i)
mxw_imgui.pop_id() pop the last pushed ID scope mxw_imgui.pop_id()
mxw_imgui.get_id(str_id) OR mxw_imgui.get_id(str_id_begin, str_id_end) OR mxw_imgui.get_id(ptr_id) compute a widget ID without pushing it uid = mxw_imgui.get_id("my_widget")

Text

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.text_unformatted(text, text_end = None) draw raw text, faster than text() for long/dynamic strings (no format parsing) mxw_imgui.text_unformatted("Ready.")
mxw_imgui.text(fmt) draw a line of text mxw_imgui.text("Frame: " + str(mxw.framecounter))
mxw_imgui.text_colored(col, fmt) draw text in the given Vec4 color mxw_imgui.text_colored(mxw_imgui.Vec4(1,0,0,1), "Error")
mxw_imgui.text_disabled(fmt) draw text in the disabled/grey style color mxw_imgui.text_disabled("(no signal)")
mxw_imgui.text_wrapped(fmt) draw text that wraps at the window edge, regardless of the wrap-pos stack mxw_imgui.text_wrapped(status_message)
mxw_imgui.label_text(label, fmt) draw a "label: value"-style line (label aligned like other widgets) mxw_imgui.label_text("Status", "OK")
mxw_imgui.bullet_text(fmt) draw a bulleted line of text mxw_imgui.bullet_text("first item")

Main widgets

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.button(label, size = Vec2(0,0)) a clickable button; returns true the frame it's clicked if mxw_imgui.button("Reload"): reload()
mxw_imgui.small_button(label) a button with no extra vertical padding, fits inline with text if mxw_imgui.small_button("x"): close()
mxw_imgui.invisible_button(str_id, size, flags = 0) an invisible clickable/draggable area mxw_imgui.invisible_button("drag_area", mxw_imgui.Vec2(50,50))
mxw_imgui.arrow_button(str_id, dir) a small square button with an arrow glyph (dir: 0=left,1=right,2=up,3=down) mxw_imgui.arrow_button("up", 2)
mxw_imgui.image(user_texture_id, size, uv0 = Vec2(0,0), uv1 = Vec2(1,1), tint_col = Vec4(1,1,1,1), border_col = Vec4(0,0,0,0)) draw a texture (GL texture id) as an image mxw_imgui.image(tex_id, mxw_imgui.Vec2(128,128))
mxw_imgui.image_button(user_texture_id, size, uv0 = Vec2(0,0), uv1 = Vec2(1,1), frame_padding = -1, bg_col = Vec4(0,0,0,0), tint_col = Vec4(1,1,1,1)) a clickable image button if mxw_imgui.image_button(tex_id, mxw_imgui.Vec2(32,32)): pass
mxw_imgui.checkbox(label, v) a checkbox; v/return is bool changed, enabled = mxw_imgui.checkbox("Enabled", enabled)
mxw_imgui.checkbox_flags(label, flags, flags_value) a checkbox that toggles one bit(mask) of an int flags value changed, flags = mxw_imgui.checkbox_flags("Bit 1", flags, 1)
mxw_imgui.radio_button(label, active) OR mxw_imgui.radio_button(label, v, v_button) a radio button; single-bool form for manual state, or bind directly to an int selection variable changed, mode = mxw_imgui.radio_button("Mode A", mode, 0)
mxw_imgui.progress_bar(fraction, size_arg = Vec2(-FLT_MIN, 0), overlay = None) a progress bar, fraction 0.0..1.0 mxw_imgui.progress_bar(0.5)
mxw_imgui.bullet() draw just a bullet glyph, e.g. before inline text/widgets mxw_imgui.bullet()

Combo box

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.combo(label, current_item, items, popup_max_height_in_items = -1) a combo box built from a Python list of strings; simplest way to pick one of several options changed, sel = mxw_imgui.combo("Mode", sel, ["A", "B", "C"])
mxw_imgui.begin_combo(label, preview_value, flags = 0) / mxw_imgui.end_combo() low-level combo box: build the popup content yourself (e.g. with selectable()) between these two calls if mxw_imgui.begin_combo("Mode", preview): mxw_imgui.end_combo()

Drag sliders

Click-and-drag widgets; typing is also possible (Ctrl+click / double-click).

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.drag_float(label, v, v_speed = 1.0, v_min = 0.0, v_max = 0.0, format = None, flags = 0) drag a single float; v_min == v_max == 0 means unbounded changed, value = mxw_imgui.drag_float("Speed", value, 0.01, 0.0, 2.0)
mxw_imgui.drag_float2(label, v, ...) / drag_float3 / drag_float4 same, for a list of 2/3/4 floats (e.g. a color or position) changed, xyz = mxw_imgui.drag_float3("Position", xyz)
mxw_imgui.drag_float_range2(label, v_current_min, v_current_max, v_speed = 1.0, v_min = 0.0, v_max = 0.0, format = None, format_max = None, flags = 0) drag a min/max float range with two handles changed, lo, hi = mxw_imgui.drag_float_range2("Range", lo, hi)
mxw_imgui.drag_int(label, v, v_speed = 1.0, v_min = 0, v_max = 0, format = None, flags = 0) drag a single int changed, value = mxw_imgui.drag_int("Count", value, 1, 0, 10)
mxw_imgui.drag_int2(label, v, ...) / drag_int3 / drag_int4 same, for a list of 2/3/4 ints changed, rgb = mxw_imgui.drag_int3("RGB", rgb, 1, 0, 255)
mxw_imgui.drag_int_range2(label, v_current_min, v_current_max, ...) drag a min/max int range with two handles changed, lo, hi = mxw_imgui.drag_int_range2("Range", lo, hi)
mxw_imgui.drag_scalar(label, data_type, p_data, v_speed, p_min = None, p_max = None, format = None, flags = 0) / drag_scalar_n(..., components, ...) generic drag widget for any ImGuiDataType, rarely needed from Python mxw_imgui.drag_scalar("Value", 0, ptr, 1.0)

Sliders

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.slider_float(label, v, v_min, v_max, format = None, flags = 0) slide a single float between v_min and v_max changed, value = mxw_imgui.slider_float("Mouse X", value, 0.0, 1.0)
mxw_imgui.slider_float2(label, v, v_min, v_max, ...) / slider_float3 / slider_float4 same, for a list of 2/3/4 floats changed, rgba = mxw_imgui.slider_float4("Color", rgba, 0.0, 1.0)
mxw_imgui.slider_angle(label, v_rad, v_degrees_min = -360.0, v_degrees_max = 360.0, format = None, flags = 0) slide an angle, stored in radians but displayed/typed in degrees changed, rot = mxw_imgui.slider_angle("Rotation", rot)
mxw_imgui.slider_int(label, v, v_min, v_max, format = None, flags = 0) slide a single int changed, idx = mxw_imgui.slider_int("Preset", idx, 0, 99)
mxw_imgui.slider_int2(label, v, v_min, v_max, ...) / slider_int3 / slider_int4 same, for a list of 2/3/4 ints changed, xy = mxw_imgui.slider_int2("Grid pos", xy, 0, 10)
mxw_imgui.slider_scalar(label, data_type, p_data, p_min, p_max, format = None, flags = 0) / slider_scalar_n(..., components, ...) generic slider for any ImGuiDataType, rarely needed from Python mxw_imgui.slider_scalar("Value", 0, ptr, p_min, p_max)
mxw_imgui.v_slider_float(label, size, v, v_min, v_max, format = None, flags = 0) vertical slider variant of slider_float changed, value = mxw_imgui.v_slider_float("##vol", mxw_imgui.Vec2(20,100), value, 0.0, 1.0)
mxw_imgui.v_slider_int(label, size, v, v_min, v_max, format = None, flags = 0) vertical slider variant of slider_int changed, value = mxw_imgui.v_slider_int("##lvl", mxw_imgui.Vec2(20,100), value, 0, 10)
mxw_imgui.v_slider_scalar(label, size, data_type, p_data, p_min, p_max, format = None, flags = 0) generic vertical slider for any ImGuiDataType mxw_imgui.v_slider_scalar("##v", size, 0, ptr, p_min, p_max)

Input widgets

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.input_text(label, data, max_size, flags = 0) a single-line text field; data is the current string, max_size the max length in bytes changed, value = mxw_imgui.input_text("URL", url_text, 512)
mxw_imgui.input_text_multiline(label, data, max_size, size = Vec2(0,0), flags = 0) a multi-line text field changed, value = mxw_imgui.input_text_multiline("Notes", notes, 2048, mxw_imgui.Vec2(300,100))
mxw_imgui.input_float(label, v, step = 0.0, step_fast = 0.0, format = None, flags = 0) a typed float field with optional +/- step buttons changed, value = mxw_imgui.input_float("Gain", value, 0.1)
mxw_imgui.input_float2(label, v, ...) / input_float3 / input_float4 same, for a list of 2/3/4 floats changed, xyz = mxw_imgui.input_float3("Pos", xyz)
mxw_imgui.input_int(label, v, step = 1, step_fast = 100, flags = 0) a typed int field with +/- step buttons changed, value = mxw_imgui.input_int("Count", value)
mxw_imgui.input_int2(label, v, flags = 0) / input_int3 / input_int4 same, for a list of 2/3/4 ints changed, rgb = mxw_imgui.input_int3("RGB", rgb)
mxw_imgui.input_double(label, v, step = 0.0, step_fast = 0.0, format = None, flags = 0) a typed double field changed, value = mxw_imgui.input_double("Precise", value)
mxw_imgui.input_scalar(label, data_type, p_data, p_step = None, p_step_fast = None, format = None, flags = 0) / input_scalar_n(..., components, ...) generic typed field for any ImGuiDataType, rarely needed from Python mxw_imgui.input_scalar("Value", 0, ptr)

Color editor & picker

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.color_edit3(label, col, flags = 0) a compact RGB color editor (swatch + popup picker); col is a 3-float list changed, rgb = mxw_imgui.color_edit3("Tint", rgb)
mxw_imgui.color_edit4(label, col, flags = 0) same, RGBA (4-float list) changed, rgba = mxw_imgui.color_edit4("Tint", rgba)
mxw_imgui.color_picker3(label, col, flags = 0) a full RGB color picker widget, always expanded changed, rgb = mxw_imgui.color_picker3("Tint", rgb)
mxw_imgui.color_picker4(label, col, flags = 0, ref_col = None) same, RGBA, optionally showing a reference color for comparison changed, rgba = mxw_imgui.color_picker4("Tint", rgba)
mxw_imgui.color_button(desc_id, col, flags = 0, size = Vec2(0,0)) a non-editable color swatch button (e.g. as a preview/trigger) if mxw_imgui.color_button("preview", col): open_picker()

Trees

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.tree_node(label) OR mxw_imgui.tree_node(str_id, fmt) OR mxw_imgui.tree_node(ptr_id, fmt) an expandable/collapsible tree node; returns true while open. Call tree_pop() if it returned true if mxw_imgui.tree_node("Advanced"): mxw_imgui.tree_pop()
mxw_imgui.tree_node_ex(label, flags = 0) OR mxw_imgui.tree_node_ex(str_id, flags, fmt) OR mxw_imgui.tree_node_ex(ptr_id, flags, fmt) tree_node() with explicit flags (e.g. default-open, leaf, selected) if mxw_imgui.tree_node_ex("Node", 0): mxw_imgui.tree_pop()
mxw_imgui.tree_push(str_id) OR mxw_imgui.tree_push(ptr_id = None) push an indent level without drawing a node (paired with tree_pop()) mxw_imgui.tree_push("scope"); mxw_imgui.tree_pop()
mxw_imgui.tree_pop() pop one indent level pushed by tree_node()/tree_push() mxw_imgui.tree_pop()
mxw_imgui.get_tree_node_to_label_spacing() returns the horizontal spacing between a tree node arrow and its label s = mxw_imgui.get_tree_node_to_label_spacing()
mxw_imgui.collapsing_header(label, flags = 0) OR mxw_imgui.collapsing_header(label, p_visible, flags = 0) a top-level collapsible section header; optionally with a close ("x") button when p_visible is passed if mxw_imgui.collapsing_header("Settings"): mxw_imgui.text("...")
mxw_imgui.set_next_item_open(is_open, cond = 0) force the next tree_node()/collapsing_header() open/closed state mxw_imgui.set_next_item_open(true)

Selectables & list boxes

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.selectable(label, selected = false, flags = 0, size = Vec2(0,0)) OR mxw_imgui.selectable(label, p_selected, flags = 0, size = Vec2(0,0)) a clickable, highlightable row (typically inside a list box) if mxw_imgui.selectable("Item 1", is_sel): pick(1)
mxw_imgui.begin_list_box(label, size = Vec2(0,0)) / mxw_imgui.end_list_box() low-level list box: build the rows yourself (e.g. with selectable()) between these two calls if mxw_imgui.begin_list_box("Items"): mxw_imgui.end_list_box()
mxw_imgui.list_box(label, current_item, items, height_in_items = -1) a list box built from a Python list of strings, single-select changed, sel = mxw_imgui.list_box("Presets", sel, ["A", "B", "C"])
mxw_imgui.list_box_stretch(label, current_item, items) MXWendler custom variant of list_box() that stretches to fill the remaining panel height changed, sel = mxw_imgui.list_box_stretch("Presets", sel, names)

Data plotting

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.plot_lines(label, values, values_offset = 0, overlay_text = None, scale_min = FLT_MAX, scale_max = FLT_MAX, graph_size = Vec2(0,0)) draw a line graph from a Python list of floats mxw_imgui.plot_lines("Levels", history)
mxw_imgui.plot_histogram(label, values, values_offset = 0, overlay_text = None, scale_min = FLT_MAX, scale_max = FLT_MAX, graph_size = Vec2(0,0)) draw a bar histogram from a Python list of floats mxw_imgui.plot_histogram("Levels", history)

Value() helpers

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.value(prefix, b) OR mxw_imgui.value(prefix, v) (int/uint) OR mxw_imgui.value(prefix, v, float_format = None) draw a "prefix: value" line for a bool/int/float, without building the string yourself mxw_imgui.value("FPS", mxw.fps)

Menus

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.begin_menu_bar() / mxw_imgui.end_menu_bar() start/end a menu bar inside the current window if mxw_imgui.begin_menu_bar(): mxw_imgui.end_menu_bar()
mxw_imgui.begin_main_menu_bar() / mxw_imgui.end_main_menu_bar() start/end the application's main (top-level) menu bar if mxw_imgui.begin_main_menu_bar(): mxw_imgui.end_main_menu_bar()
mxw_imgui.begin_menu(label, enabled = true) / mxw_imgui.end_menu() start/end a (sub)menu; call end_menu() only if begin_menu() returned true if mxw_imgui.begin_menu("File"): mxw_imgui.end_menu()
mxw_imgui.menu_item(label, shortcut = None, selected = false, enabled = true) OR mxw_imgui.menu_item(label, shortcut, p_selected, enabled = true) a clickable (optionally checkable) menu entry if mxw_imgui.menu_item("Save", "Ctrl+S"): save()

Tooltips

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.begin_tooltip() / mxw_imgui.end_tooltip() build a custom tooltip (any widgets) between these two calls mxw_imgui.begin_tooltip(); mxw_imgui.text("info"); mxw_imgui.end_tooltip()
mxw_imgui.set_tooltip(fmt) a quick one-line tooltip for the last hovered item if mxw_imgui.is_item_hovered(): mxw_imgui.set_tooltip("Explain this")

Popups & modals

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.open_popup(str_id, flags = 0) flag a popup to open (by ID) on the next matching begin_popup() mxw_imgui.open_popup("confirm_delete")
mxw_imgui.begin_popup(str_id, flags = 0) / mxw_imgui.end_popup() build a plain popup's content; call end_popup() only if begin_popup() returned true if mxw_imgui.begin_popup("menu"): mxw_imgui.end_popup()
mxw_imgui.begin_popup_modal(name, p_open = None, flags = 0) build a modal popup's content (blocks interaction with the rest of the UI) opened, _ = mxw_imgui.begin_popup_modal("Confirm")
mxw_imgui.open_popup_on_item_click(str_id = None, popup_flags = 1) open a popup when the last item is clicked (e.g. right-click context menu) mxw_imgui.open_popup_on_item_click("ctx")
mxw_imgui.close_current_popup() close the popup currently being drawn (e.g. after a button inside it) if mxw_imgui.button("OK"): mxw_imgui.close_current_popup()
mxw_imgui.begin_popup_context_item(str_id = None, popup_flags = 1) combined open+begin for a right-click context popup on the last item if mxw_imgui.begin_popup_context_item(): mxw_imgui.end_popup()
mxw_imgui.begin_popup_context_window(str_id = None, popup_flags = 1) same, anchored to the current window instead of the last item if mxw_imgui.begin_popup_context_window(): mxw_imgui.end_popup()
mxw_imgui.begin_popup_context_void(str_id = None, popup_flags = 1) same, opens on right-click on empty space (no window/item under cursor) if mxw_imgui.begin_popup_context_void(): mxw_imgui.end_popup()
mxw_imgui.is_popup_open(str_id, flags = 0) returns whether the given popup is currently open open = mxw_imgui.is_popup_open("menu")

Tables

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.begin_table(str_id, column, flags = 0, outer_size = Vec2(0,0), inner_width = 0.0) / mxw_imgui.end_table() start/end a table; call end_table() only if begin_table() returned true if mxw_imgui.begin_table("grid", 3): mxw_imgui.end_table()
mxw_imgui.table_next_row(row_flags = 0, min_row_height = 0.0) start the next table row mxw_imgui.table_next_row()
mxw_imgui.table_next_column() advance to the next cell (wraps to the next row automatically) mxw_imgui.table_next_column()
mxw_imgui.table_set_column_index(column_n) jump directly to a given column in the current row mxw_imgui.table_set_column_index(1)
mxw_imgui.table_setup_column(label, flags = 0, init_width_or_weight = 0.0, user_id = 0) declare a column's header label / sizing before the first row mxw_imgui.table_setup_column("Name")
mxw_imgui.table_setup_scroll_freeze(cols, rows) freeze N leading columns/rows while the rest scrolls mxw_imgui.table_setup_scroll_freeze(0, 1)
mxw_imgui.table_headers_row() draw the header row from the declared table_setup_column() labels mxw_imgui.table_headers_row()
mxw_imgui.table_header(label) draw a single header cell manually (instead of table_headers_row()) mxw_imgui.table_header("Name")
mxw_imgui.table_get_sort_specs() returns the current column sort specification, if the table is sortable specs = mxw_imgui.table_get_sort_specs()
mxw_imgui.table_get_column_count() returns the number of columns of the current table n = mxw_imgui.table_get_column_count()
mxw_imgui.table_get_column_index() returns the current column index i = mxw_imgui.table_get_column_index()
mxw_imgui.table_get_row_index() returns the current row index i = mxw_imgui.table_get_row_index()
mxw_imgui.table_get_column_name(column_n = -1) returns a column's declared label (-1 = current column) name = mxw_imgui.table_get_column_name(0)
mxw_imgui.table_get_column_flags(column_n = -1) returns a column's current flags (e.g. is it hidden/sorted) flags = mxw_imgui.table_get_column_flags()
mxw_imgui.table_set_bg_color(target, color, column_n = -1) set the background color of a cell/row/column mxw_imgui.table_set_bg_color(0, mxw_imgui.color_convert_float4_to_u32(mxw_imgui.Vec4(1,0,0,1)))

Legacy columns

Superseded by Tables above, kept for compatibility.

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.columns(count = 1, id = None, border = true) switch the rest of the window into a simple N-column layout (count = 1 ends it) mxw_imgui.columns(2)
mxw_imgui.next_column() move to the next column (wraps to the next row) mxw_imgui.next_column()
mxw_imgui.get_column_index() returns the current column index i = mxw_imgui.get_column_index()
mxw_imgui.get_column_width(column_index = -1) / mxw_imgui.set_column_width(column_index, width) get/set a column's width w = mxw_imgui.get_column_width()
mxw_imgui.get_column_offset(column_index = -1) / mxw_imgui.set_column_offset(column_index, offset_x) get/set a column's X offset x = mxw_imgui.get_column_offset()
mxw_imgui.get_columns_count() returns the current column count n = mxw_imgui.get_columns_count()

Tabs

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.begin_tab_bar(str_id, flags = 0) / mxw_imgui.end_tab_bar() start/end a tab bar; call end_tab_bar() only if begin_tab_bar() returned true if mxw_imgui.begin_tab_bar("tabs"): mxw_imgui.end_tab_bar()
mxw_imgui.begin_tab_item(label, p_open = None, flags = 0) / mxw_imgui.end_tab_item() start/end one tab's content; call end_tab_item() only if begin_tab_item() returned true opened, _ = mxw_imgui.begin_tab_item("Settings")
mxw_imgui.tab_item_button(label, flags = 0) a button drawn as a tab (e.g. a "+" to add a tab) if mxw_imgui.tab_item_button("+"): add_tab()
mxw_imgui.set_tab_item_closed(tab_or_docked_window_label) programmatically close a tab by label mxw_imgui.set_tab_item_closed("Old Tab")

Logging / capture

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.log_to_tty(auto_open_depth = -1) start capturing following widgets' text output to the app's TTY/console mxw_imgui.log_to_tty()
mxw_imgui.log_to_file(auto_open_depth = -1, filename = None) start capturing to a file mxw_imgui.log_to_file(-1, "log.txt")
mxw_imgui.log_to_clipboard(auto_open_depth = -1) start capturing to the OS clipboard mxw_imgui.log_to_clipboard()
mxw_imgui.log_finish() stop the current capture mxw_imgui.log_finish()
mxw_imgui.log_buttons() draw the standard "Log/Copy to clipboard" buttons mxw_imgui.log_buttons()
mxw_imgui.log_text(fmt) add text directly to the active log capture, without drawing a widget mxw_imgui.log_text("captured line")

Drag and drop

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.begin_drag_drop_source(flags = 0) / mxw_imgui.end_drag_drop_source() make the last item a drag source; build the payload/preview between these two calls if mxw_imgui.begin_drag_drop_source(): mxw_imgui.end_drag_drop_source()
mxw_imgui.set_drag_drop_payload(type, data, sz, cond = 0) attach a payload to the drag currently being sourced mxw_imgui.set_drag_drop_payload("CLIP", data, len(data))
mxw_imgui.begin_drag_drop_target() / mxw_imgui.end_drag_drop_target() make the last item/window a drop target; check accept_drag_drop_payload() between these two calls if mxw_imgui.begin_drag_drop_target(): mxw_imgui.end_drag_drop_target()
mxw_imgui.accept_drag_drop_payload(type, flags = 0) accept a payload of the given type while inside a drop target p = mxw_imgui.accept_drag_drop_payload("CLIP")
mxw_imgui.get_drag_drop_payload() peek the payload of the drag currently in progress, even outside a target p = mxw_imgui.get_drag_drop_payload()

Clipping

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.push_clip_rect(clip_rect_min, clip_rect_max, intersect_with_current_clip_rect) push a manual clipping rectangle (Vec2 corners) for subsequent drawing mxw_imgui.push_clip_rect(p_min, p_max, true)
mxw_imgui.pop_clip_rect() pop the pushed clip rect mxw_imgui.pop_clip_rect()

Focus & activation

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.set_item_default_focus() make the last item the one focused by default when the panel first appears mxw_imgui.set_item_default_focus()
mxw_imgui.set_keyboard_focus_here(offset = 0) focus the next widget for keyboard input (e.g. auto-focus a text field) mxw_imgui.set_keyboard_focus_here()

Item / widgets utilities

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.is_item_hovered(flags = 0) returns whether the last item is hovered by the mouse if mxw_imgui.is_item_hovered(): mxw_imgui.set_tooltip("info")
mxw_imgui.is_item_active() returns whether the last item is currently active (e.g. being held/edited) active = mxw_imgui.is_item_active()
mxw_imgui.is_item_focused() returns whether the last item has keyboard focus focused = mxw_imgui.is_item_focused()
mxw_imgui.is_item_clicked(mouse_button = 0) returns whether the last item was clicked this frame if mxw_imgui.is_item_clicked(): pass
mxw_imgui.is_item_visible() returns whether the last item is visible (not clipped) visible = mxw_imgui.is_item_visible()
mxw_imgui.is_item_edited() returns whether the last item's value changed this frame edited = mxw_imgui.is_item_edited()
mxw_imgui.is_item_activated() returns whether the last item just became active this frame started = mxw_imgui.is_item_activated()
mxw_imgui.is_item_deactivated() returns whether the last item just stopped being active this frame stopped = mxw_imgui.is_item_deactivated()
mxw_imgui.is_item_deactivated_after_edit() returns whether the last item stopped being active after its value changed (e.g. commit-on-release) if mxw_imgui.is_item_deactivated_after_edit(): save()
mxw_imgui.is_item_toggled_open() returns whether the last tree node/collapsing header was just opened or closed toggled = mxw_imgui.is_item_toggled_open()
mxw_imgui.is_any_item_hovered() / mxw_imgui.is_any_item_active() / mxw_imgui.is_any_item_focused() returns whether any item at all is hovered/active/focused busy = mxw_imgui.is_any_item_active()
mxw_imgui.get_item_rect_min() / mxw_imgui.get_item_rect_max() / mxw_imgui.get_item_rect_size() returns the last item's bounding rectangle (screen-space corners, or size) size = mxw_imgui.get_item_rect_size()
mxw_imgui.set_item_allow_overlap() allow the next widget to visually overlap the last item without stealing its hover/click mxw_imgui.set_item_allow_overlap()

Viewport & miscellaneous

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.get_main_viewport() returns the main viewport object (position/size of the whole application) vp = mxw_imgui.get_main_viewport()
mxw_imgui.is_rect_visible(size) OR mxw_imgui.is_rect_visible(rect_min, rect_max) returns whether a rectangle at the cursor (or explicit corners) is visible/unclipped visible = mxw_imgui.is_rect_visible(mxw_imgui.Vec2(50,50))
mxw_imgui.get_time() returns Dear ImGui's internal time in seconds (accumulates while the app runs) t = mxw_imgui.get_time()
mxw_imgui.get_frame_count() returns the number of ImGui frames rendered so far n = mxw_imgui.get_frame_count()
mxw_imgui.get_background_draw_list() / mxw_imgui.get_foreground_draw_list() returns the draw list rendered behind/in front of all windows, for custom drawing dl = mxw_imgui.get_foreground_draw_list()
mxw_imgui.get_draw_list_shared_data() returns data shared across draw lists (font atlas, clip rect stack, ...), rarely needed from Python d = mxw_imgui.get_draw_list_shared_data()
mxw_imgui.set_state_storage(storage) / mxw_imgui.get_state_storage() set/get the key-value storage backing tree/collapsing-header open states s = mxw_imgui.get_state_storage()
mxw_imgui.begin_child_frame(id, size, flags = 0) / mxw_imgui.end_child_frame() a framed, scrollable child region (styled like a text/list box) if mxw_imgui.begin_child_frame(1, mxw_imgui.Vec2(0,100)): mxw_imgui.end_child_frame()
mxw_imgui.calc_text_size(text, text_end = None, hide_text_after_double_hash = false, wrap_width = -1.0) returns the pixel size a string would occupy with the current font w = mxw_imgui.calc_text_size("0").x

Color utilities

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.color_convert_u32_to_float4(in) convert a packed u32 color to a Vec4 col = mxw_imgui.color_convert_u32_to_float4(0xFFFFFFFF)
mxw_imgui.color_convert_float4_to_u32(in) convert a Vec4 color to a packed u32 u = mxw_imgui.color_convert_float4_to_u32(mxw_imgui.Vec4(1,1,1,1))
mxw_imgui.color_convert_rg_bto_hsv(r, g, b) returns (h, s, v) for the given RGB floats (0.0..1.0) h, s, v = mxw_imgui.color_convert_rg_bto_hsv(1.0, 0.0, 0.0)
mxw_imgui.color_convert_hs_vto_rgb(h, s, v) returns (r, g, b) for the given HSV floats (0.0..1.0) r, g, b = mxw_imgui.color_convert_hs_vto_rgb(0.0, 1.0, 1.0)

Keyboard input

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.get_key_index(imgui_key) map a Dear ImGui ImGuiKey_* value to the user's backend key index idx = mxw_imgui.get_key_index(0)
mxw_imgui.is_key_down(user_key_index) returns whether a key is currently held down held = mxw_imgui.is_key_down(idx)
mxw_imgui.is_key_pressed(user_key_index, repeat = true) returns whether a key was just pressed (optionally auto-repeating while held) if mxw_imgui.is_key_pressed(idx): pass
mxw_imgui.is_key_released(user_key_index) returns whether a key was just released if mxw_imgui.is_key_released(idx): pass
mxw_imgui.get_key_pressed_amount(key_index, repeat_delay, rate) returns how many times a key auto-repeated this frame, given a delay/rate n = mxw_imgui.get_key_pressed_amount(idx, 0.3, 0.1)

Mouse input

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.is_mouse_down(button) returns whether a mouse button is currently held (0=left,1=right,2=middle) held = mxw_imgui.is_mouse_down(0)
mxw_imgui.is_mouse_clicked(button, repeat = false) returns whether a mouse button was just clicked if mxw_imgui.is_mouse_clicked(0): pass
mxw_imgui.is_mouse_released(button) returns whether a mouse button was just released if mxw_imgui.is_mouse_released(0): pass
mxw_imgui.is_mouse_double_clicked(button) returns whether a mouse button was just double-clicked if mxw_imgui.is_mouse_double_clicked(0): pass
mxw_imgui.is_mouse_hovering_rect(r_min, r_max, clip = true) returns whether the mouse is over the given screen-space rectangle over = mxw_imgui.is_mouse_hovering_rect(p_min, p_max)
mxw_imgui.is_mouse_pos_valid(mouse_pos = None) returns whether the (current or given) mouse position is valid (app has focus etc.) valid = mxw_imgui.is_mouse_pos_valid()
mxw_imgui.is_any_mouse_down() returns whether any mouse button is currently held held = mxw_imgui.is_any_mouse_down()
mxw_imgui.get_mouse_pos() returns the current mouse position (Vec2, screen-space) p = mxw_imgui.get_mouse_pos()
mxw_imgui.get_mouse_pos_on_opening_current_popup() returns the mouse position captured when the current popup was opened p = mxw_imgui.get_mouse_pos_on_opening_current_popup()
mxw_imgui.is_mouse_dragging(button, lock_threshold = -1.0) returns whether the mouse is dragging with the given button held dragging = mxw_imgui.is_mouse_dragging(0)
mxw_imgui.get_mouse_drag_delta(button = 0, lock_threshold = -1.0) returns the drag distance (Vec2) since the drag started d = mxw_imgui.get_mouse_drag_delta()
mxw_imgui.reset_mouse_drag_delta(button = 0) reset the tracked drag distance for a button mxw_imgui.reset_mouse_drag_delta()
mxw_imgui.get_mouse_cursor() / mxw_imgui.set_mouse_cursor(cursor_type) get/set the desired OS mouse cursor shape mxw_imgui.set_mouse_cursor(1)

Clipboard

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.get_clipboard_text() returns the current OS clipboard text txt = mxw_imgui.get_clipboard_text()
mxw_imgui.set_clipboard_text(text) set the OS clipboard text mxw_imgui.set_clipboard_text("copied value")

Disabled blocks & MXWendler extras

The last two functions are MXWendler additions, not part of stock Dear ImGui bindings.

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
mxw_imgui.begin_disabled(disabled = false) / mxw_imgui.end_disabled() grey out and block interaction with all widgets in between mxw_imgui.begin_disabled(not enabled); mxw_imgui.button("Go"); mxw_imgui.end_disabled()
mxw_imgui.render_frame(p_min, p_max, colf, border = true, rounding = 0.0) draw a filled/bordered rectangle (screen-space corners as Vec2, color as Vec4) directly, e.g. for custom backgrounds mxw_imgui.render_frame(mxw_imgui.Vec2(0,0), mxw_imgui.Vec2(100,20), mxw_imgui.Vec4(0.2,0.2,0.2,1))