Cython-based Python bindings for dear imgui - a bloat-free immediate mode graphical user interface library
—
Comprehensive collection of interactive UI elements including buttons, text inputs, sliders, checkboxes, combo boxes, color pickers, and more. These widgets handle user input and return their current state, forming the core interactive elements of ImGui applications.
Functions for displaying various types of text content with different formatting and behavior.
def text(text: str) -> None:
"""Display regular text."""
def text_colored(text: str, r: float, g: float, b: float, a: float = 1.0) -> None:
"""Display colored text."""
def text_disabled(text: str) -> None:
"""Display disabled (grayed out) text."""
def text_wrapped(text: str) -> None:
"""Display text with word wrapping."""
def text_unformatted(text: str) -> None:
"""Display large amounts of text efficiently."""
def label_text(label: str, text: str) -> None:
"""Display text with a label prefix."""
def bullet_text(text: str) -> None:
"""Display text with a bullet point."""
def bullet() -> None:
"""Display a bullet point and keep cursor on same line."""Various types of clickable button widgets for user interaction.
def button(label: str, width: float = 0, height: float = 0) -> bool:
"""Regular button. Returns True when clicked."""
def small_button(label: str) -> bool:
"""Small button with minimal padding. Returns True when clicked."""
def arrow_button(label: str, direction: int) -> bool:
"""Square button with arrow. Returns True when clicked."""
def invisible_button(identifier: str, width: float, height: float, flags: int = 0) -> bool:
"""Invisible button for custom drawing areas. Returns True when clicked."""
def color_button(desc_id: str, r: float, g: float, b: float, a: float = 1.0, flags: int = 0, width: float = 0, height: float = 0) -> bool:
"""Color square button. Returns True when clicked."""
def image_button(texture_id: int, width: float, height: float, uv0: tuple = (0,0), uv1: tuple = (1,1), bg_color: tuple = (0,0,0,0), tint_color: tuple = (1,1,1,1)) -> bool:
"""Image button. Returns True when clicked."""Widgets for selecting options, including checkboxes, radio buttons, and selection lists.
def checkbox(label: str, state: bool) -> tuple[bool, bool]:
"""Checkbox widget. Returns (changed, current_state)."""
def checkbox_flags(label: str, flags: int, flags_value: int) -> tuple[bool, int]:
"""Checkbox for integer flags. Returns (changed, new_flags)."""
def radio_button(label: str, active: bool) -> bool:
"""Radio button. Returns True when clicked."""
def selectable(label: str, selected: bool = False, flags: int = 0, width: float = 0, height: float = 0) -> tuple[bool, bool]:
"""Selectable item. Returns (clicked, selected_state)."""
def listbox(label: str, current: int, items: list[str], height_in_items: int = -1) -> tuple[bool, int]:
"""Simple listbox. Returns (changed, selected_index)."""
def begin_list_box(label: str, width: float = 0, height: float = 0) -> bool:
"""Begin manual listbox. Returns True if listbox is open."""
def end_list_box() -> None:
"""End manual listbox."""Widgets for text entry and editing with various input modes and validation.
def input_text(label: str, value: str, buffer_length: int, flags: int = 0) -> tuple[bool, str]:
"""Single-line text input. Returns (changed, new_text)."""
def input_text_multiline(label: str, value: str, buffer_length: int, width: float = 0, height: float = 0, flags: int = 0) -> tuple[bool, str]:
"""Multi-line text input. Returns (changed, new_text)."""
def input_text_with_hint(label: str, hint: str, value: str, buffer_length: int, flags: int = 0) -> tuple[bool, str]:
"""Text input with placeholder hint. Returns (changed, new_text)."""Widgets for entering and editing numeric values with validation and formatting.
def input_float(label: str, value: float, step: float = 0.0, step_fast: float = 0.0, format: str = "%.3f", flags: int = 0) -> tuple[bool, float]:
"""Float input field. Returns (changed, new_value)."""
def input_float2(label: str, values: tuple[float, float], format: str = "%.3f", flags: int = 0) -> tuple[bool, tuple[float, float]]:
"""2-component float input. Returns (changed, (x, y))."""
def input_float3(label: str, values: tuple[float, float, float], format: str = "%.3f", flags: int = 0) -> tuple[bool, tuple[float, float, float]]:
"""3-component float input. Returns (changed, (x, y, z))."""
def input_float4(label: str, values: tuple[float, float, float, float], format: str = "%.3f", flags: int = 0) -> tuple[bool, tuple[float, float, float, float]]:
"""4-component float input. Returns (changed, (x, y, z, w))."""
def input_int(label: str, value: int, step: int = 1, step_fast: int = 100, flags: int = 0) -> tuple[bool, int]:
"""Integer input field. Returns (changed, new_value)."""
def input_int2(label: str, values: tuple[int, int], flags: int = 0) -> tuple[bool, tuple[int, int]]:
"""2-component integer input. Returns (changed, (x, y))."""
def input_int3(label: str, values: tuple[int, int, int], flags: int = 0) -> tuple[bool, tuple[int, int, int]]:
"""3-component integer input. Returns (changed, (x, y, z))."""
def input_int4(label: str, values: tuple[int, int, int, int], flags: int = 0) -> tuple[bool, tuple[int, int, int, int]]:
"""4-component integer input. Returns (changed, (x, y, z, w))."""
def input_double(label: str, value: float, step: float = 0.0, step_fast: float = 0.0, format: str = "%.6f", flags: int = 0) -> tuple[bool, float]:
"""Double precision input field. Returns (changed, new_value)."""Interactive slider controls for numeric value selection within specified ranges.
def slider_float(label: str, value: float, v_min: float, v_max: float, format: str = "%.3f", flags: int = 0) -> tuple[bool, float]:
"""Float slider. Returns (changed, new_value)."""
def slider_float2(label: str, values: tuple[float, float], v_min: float, v_max: float, format: str = "%.3f", flags: int = 0) -> tuple[bool, tuple[float, float]]:
"""2-component float slider. Returns (changed, (x, y))."""
def slider_float3(label: str, values: tuple[float, float, float], v_min: float, v_max: float, format: str = "%.3f", flags: int = 0) -> tuple[bool, tuple[float, float, float]]:
"""3-component float slider. Returns (changed, (x, y, z))."""
def slider_float4(label: str, values: tuple[float, float, float, float], v_min: float, v_max: float, format: str = "%.3f", flags: int = 0) -> tuple[bool, tuple[float, float, float, float]]:
"""4-component float slider. Returns (changed, (x, y, z, w))."""
def slider_int(label: str, value: int, v_min: int, v_max: int, format: str = "%d", flags: int = 0) -> tuple[bool, int]:
"""Integer slider. Returns (changed, new_value)."""
def slider_int2(label: str, values: tuple[int, int], v_min: int, v_max: int, format: str = "%d", flags: int = 0) -> tuple[bool, tuple[int, int]]:
"""2-component integer slider. Returns (changed, (x, y))."""
def slider_int3(label: str, values: tuple[int, int, int], v_min: int, v_max: int, format: str = "%d", flags: int = 0) -> tuple[bool, tuple[int, int, int]]:
"""3-component integer slider. Returns (changed, (x, y, z))."""
def slider_int4(label: str, values: tuple[int, int, int, int], v_min: int, v_max: int, format: str = "%d", flags: int = 0) -> tuple[bool, tuple[int, int, int, int]]:
"""4-component integer slider. Returns (changed, (x, y, z, w))."""
def slider_angle(label: str, v_rad: float, v_degrees_min: float = -360.0, v_degrees_max: float = 360.0, format: str = "%.0f deg", flags: int = 0) -> tuple[bool, float]:
"""Angle slider in radians. Returns (changed, new_value)."""
def v_slider_float(label: str, width: float, height: float, value: float, v_min: float, v_max: float, format: str = "%.3f", flags: int = 0) -> tuple[bool, float]:
"""Vertical float slider. Returns (changed, new_value)."""
def v_slider_int(label: str, width: float, height: float, value: int, v_min: int, v_max: int, format: str = "%d", flags: int = 0) -> tuple[bool, int]:
"""Vertical integer slider. Returns (changed, new_value)."""Drag controls for fine-tuned numeric value adjustment with mouse movement.
def drag_float(label: str, value: float, v_speed: float = 1.0, v_min: float = 0.0, v_max: float = 0.0, format: str = "%.3f", flags: int = 0) -> tuple[bool, float]:
"""Float drag control. Returns (changed, new_value)."""
def drag_float2(label: str, values: tuple[float, float], v_speed: float = 1.0, v_min: float = 0.0, v_max: float = 0.0, format: str = "%.3f", flags: int = 0) -> tuple[bool, tuple[float, float]]:
"""2-component float drag. Returns (changed, (x, y))."""
def drag_float3(label: str, values: tuple[float, float, float], v_speed: float = 1.0, v_min: float = 0.0, v_max: float = 0.0, format: str = "%.3f", flags: int = 0) -> tuple[bool, tuple[float, float, float]]:
"""3-component float drag. Returns (changed, (x, y, z))."""
def drag_float4(label: str, values: tuple[float, float, float, float], v_speed: float = 1.0, v_min: float = 0.0, v_max: float = 0.0, format: str = "%.3f", flags: int = 0) -> tuple[bool, tuple[float, float, float, float]]:
"""4-component float drag. Returns (changed, (x, y, z, w))."""
def drag_int(label: str, value: int, v_speed: float = 1.0, v_min: int = 0, v_max: int = 0, format: str = "%d", flags: int = 0) -> tuple[bool, int]:
"""Integer drag control. Returns (changed, new_value)."""
def drag_int2(label: str, values: tuple[int, int], v_speed: float = 1.0, v_min: int = 0, v_max: int = 0, format: str = "%d", flags: int = 0) -> tuple[bool, tuple[int, int]]:
"""2-component integer drag. Returns (changed, (x, y))."""
def drag_int3(label: str, values: tuple[int, int, int], v_speed: float = 1.0, v_min: int = 0, v_max: int = 0, format: str = "%d", flags: int = 0) -> tuple[bool, tuple[int, int, int]]:
"""3-component integer drag. Returns (changed, (x, y, z))."""
def drag_int4(label: str, values: tuple[int, int, int, int], v_speed: float = 1.0, v_min: int = 0, v_max: int = 0, format: str = "%d", flags: int = 0) -> tuple[bool, tuple[int, int, int, int]]:
"""4-component integer drag. Returns (changed, (x, y, z, w))."""
def drag_float_range2(label: str, v_current_min: float, v_current_max: float, v_speed: float = 1.0, v_min: float = 0.0, v_max: float = 0.0, format: str = "%.3f", format_max: str = None, flags: int = 0) -> tuple[bool, float, float]:
"""Float range drag control. Returns (changed, new_min, new_max)."""
def drag_int_range2(label: str, v_current_min: int, v_current_max: int, v_speed: float = 1.0, v_min: int = 0, v_max: int = 0, format: str = "%d", format_max: str = None, flags: int = 0) -> tuple[bool, int, int]:
"""Integer range drag control. Returns (changed, new_min, new_max)."""Color selection and editing widgets with various display modes and formats.
def color_edit3(label: str, r: float, g: float, b: float, flags: int = 0) -> tuple[bool, float, float, float]:
"""RGB color editor. Returns (changed, r, g, b)."""
def color_edit4(label: str, r: float, g: float, b: float, a: float, flags: int = 0) -> tuple[bool, float, float, float, float]:
"""RGBA color editor. Returns (changed, r, g, b, a)."""Dropdown selection widgets for choosing from predefined options.
def combo(label: str, current: int, items: list[str], height_in_items: int = -1) -> tuple[bool, int]:
"""Simple combo box. Returns (changed, selected_index)."""
def begin_combo(label: str, preview_value: str, flags: int = 0) -> bool:
"""Begin manual combo box. Returns True if combo is open."""
def end_combo() -> None:
"""End manual combo box."""Widgets for displaying hierarchical data and collapsible content sections.
def tree_node(text: str, flags: int = 0) -> bool:
"""Tree node widget. Returns True if open."""
def tree_pop() -> None:
"""Pop tree node from stack."""
def collapsing_header(text: str, visible: bool = None, flags: int = 0) -> tuple[bool, bool]:
"""Collapsing header widget. Returns (open, visible)."""
def set_next_item_open(is_open: bool, condition: int = 0) -> None:
"""Set next tree node open state."""
def get_tree_node_to_label_spacing() -> float:
"""Get spacing between tree node and label."""Simple plotting widgets for displaying data visualizations.
def plot_lines(label: str, values: list[float], values_count: int = 0, values_offset: int = 0, overlay_text: str = "", scale_min: float = None, scale_max: float = None, graph_width: float = 0, graph_height: float = 0) -> None:
"""Plot lines graph."""
def plot_histogram(label: str, values: list[float], values_count: int = 0, values_offset: int = 0, overlay_text: str = "", scale_min: float = None, scale_max: float = None, graph_width: float = 0, graph_height: float = 0) -> None:
"""Plot histogram."""Miscellaneous widgets for specialized functionality.
def image(texture_id: int, width: float, height: float, uv0: tuple = (0,0), uv1: tuple = (1,1), tint_color: tuple = (1,1,1,1), border_color: tuple = (0,0,0,0)) -> None:
"""Display image."""
def progress_bar(fraction: float, size: tuple = (-1, 0), overlay: str = "") -> None:
"""Progress bar widget."""
def set_tooltip(text: str) -> None:
"""Set tooltip text for last item."""
def begin_tooltip() -> bool:
"""Begin custom tooltip window."""
def end_tooltip() -> None:
"""End custom tooltip window."""import imgui
# Text display
imgui.text("Regular text")
imgui.text_colored("Colored text", 1.0, 0.0, 0.0) # Red
imgui.text_disabled("Disabled text")
# Buttons
if imgui.button("Click Me"):
print("Button clicked!")
if imgui.small_button("Small"):
print("Small button clicked!")
# Checkbox
checkbox_state = True
changed, checkbox_state = imgui.checkbox("Enable option", checkbox_state)
if changed:
print(f"Checkbox now: {checkbox_state}")# Text input
text_buffer = "Hello World"
changed, text_buffer = imgui.input_text("Text", text_buffer, 256)
# Numeric inputs
float_value = 3.14
changed, float_value = imgui.input_float("Float", float_value)
int_value = 42
changed, int_value = imgui.input_int("Integer", int_value)
# Multi-component inputs
vec3 = (1.0, 2.0, 3.0)
changed, vec3 = imgui.input_float3("Vector3", vec3)# Sliders
slider_value = 0.5
changed, slider_value = imgui.slider_float("Slider", slider_value, 0.0, 1.0)
# Drag controls
drag_value = 10.0
changed, drag_value = imgui.drag_float("Drag", drag_value, 0.1, 0.0, 100.0)
# Range controls
min_val, max_val = 10.0, 90.0
changed, min_val, max_val = imgui.drag_float_range2("Range", min_val, max_val, 1.0, 0.0, 100.0)# Combo box
current_item = 0
items = ["Item 1", "Item 2", "Item 3"]
changed, current_item = imgui.combo("Combo", current_item, items)
# Listbox
listbox_item = 0
changed, listbox_item = imgui.listbox("List", listbox_item, items)
# Selectable items
selected = False
clicked, selected = imgui.selectable("Selectable item", selected)# RGB color
color_rgb = (1.0, 0.5, 0.2)
changed, *color_rgb = imgui.color_edit3("RGB Color", *color_rgb)
# RGBA color with alpha
color_rgba = (1.0, 0.5, 0.2, 0.8)
changed, *color_rgba = imgui.color_edit4("RGBA Color", *color_rgba)# Simple tree node
if imgui.tree_node("Tree Node"):
imgui.text("Content inside tree node")
imgui.tree_pop()
# Collapsing header
opened, visible = imgui.collapsing_header("Collapsing Header")
if opened:
imgui.text("Content inside collapsing header")Install with Tessl CLI
npx tessl i tessl/pypi-imgui