Cython-based Python bindings for dear imgui - a bloat-free immediate mode graphical user interface library
—
Essential window operations for creating, positioning, sizing, and managing window states. Windows are the fundamental containers for all ImGui content and provide the basic structure for organizing UI elements.
Core functions for creating and managing windows with various properties and behaviors.
def begin(label: str, closable: bool = False, flags: int = 0) -> bool:
"""Begin a new window. Returns True if window is not collapsed."""
def end() -> None:
"""End the current window. Must be called after begin()."""
def begin_child(label: str, width: float = 0, height: float = 0, border: bool = False, flags: int = 0) -> bool:
"""Begin a scrolling region (child window). Returns True if region is visible."""
def end_child() -> None:
"""End the current child window."""Functions to query and control window dimensions, position, and visibility states.
def get_window_position() -> tuple[float, float]:
"""Get current window position as (x, y)."""
def get_window_size() -> tuple[float, float]:
"""Get current window size as (width, height)."""
def get_window_width() -> float:
"""Get current window width."""
def get_window_height() -> float:
"""Get current window height."""
def is_window_collapsed() -> bool:
"""Check if current window is collapsed."""
def is_window_appearing() -> bool:
"""Check if current window is appearing this frame."""
def is_window_hovered(flags: int = 0) -> bool:
"""Check if current window is hovered by mouse."""
def is_window_focused(flags: int = 0) -> bool:
"""Check if current window is focused."""Functions to programmatically control window placement and dimensions.
def set_window_focus() -> None:
"""Set current window to be focused."""
def set_window_focus_labeled(label: str) -> None:
"""Set named window to be focused."""
def set_window_size(width: float, height: float, condition: int = ONCE) -> None:
"""Set current window size."""
def set_window_size_named(label: str, width: float, height: float, condition: int = ONCE) -> None:
"""Set named window size."""
def set_window_position(x: float, y: float, condition: int = ALWAYS) -> None:
"""Set current window position."""
def set_window_position_labeled(label: str, x: float, y: float, condition: int = ALWAYS) -> None:
"""Set named window position."""
def set_window_collapsed(collapsed: bool, condition: int = ALWAYS) -> None:
"""Set current window collapsed state."""
def set_window_collapsed_labeled(label: str, collapsed: bool, condition: int = ALWAYS) -> None:
"""Set named window collapsed state."""
def set_window_font_scale(scale: float) -> None:
"""Adjust per-window font scale."""Functions to configure properties for the next window before calling begin().
def set_next_window_position(x: float, y: float, condition: int = ALWAYS, pivot_x: float = 0, pivot_y: float = 0) -> None:
"""Set next window position with optional pivot point."""
def set_next_window_size(width: float, height: float, condition: int = ALWAYS) -> None:
"""Set next window size."""
def set_next_window_size_constraints(size_min: tuple[float, float], size_max: tuple[float, float]) -> None:
"""Set next window size constraints."""
def set_next_window_content_size(width: float, height: float) -> None:
"""Set next window content size (with scrollbars)."""
def set_next_window_collapsed(collapsed: bool, condition: int = ALWAYS) -> None:
"""Set next window collapsed state."""
def set_next_window_focus() -> None:
"""Set next window to be focused."""
def set_next_window_bg_alpha(alpha: float) -> None:
"""Set next window background alpha."""Functions to query available space within windows for proper layout calculations.
def get_content_region_max() -> tuple[float, float]:
"""Get maximal content boundaries."""
def get_content_region_available() -> tuple[float, float]:
"""Get available content region size."""
def get_content_region_available_width() -> float:
"""Get available content region width."""
def get_window_content_region_min() -> tuple[float, float]:
"""Get minimal content boundaries."""
def get_window_content_region_max() -> tuple[float, float]:
"""Get maximal content boundaries."""
def get_window_content_region_width() -> float:
"""Get content region width."""Common window flag constants for controlling window behavior:
# Basic window flags
WINDOW_NONE: int
WINDOW_NO_TITLE_BAR: int # Disable title-bar
WINDOW_NO_RESIZE: int # Disable user resizing
WINDOW_NO_MOVE: int # Disable user moving
WINDOW_NO_SCROLLBAR: int # Disable scrollbars
WINDOW_NO_SCROLL_WITH_MOUSE: int # Disable scroll with mouse wheel
WINDOW_NO_COLLAPSE: int # Disable collapsing with double-click
WINDOW_ALWAYS_AUTO_RESIZE: int # Resize to content every frame
WINDOW_NO_BACKGROUND: int # Disable background drawing
WINDOW_NO_SAVED_SETTINGS: int # Never load/save settings
WINDOW_NO_MOUSE_INPUTS: int # Disable mouse input catching
WINDOW_MENU_BAR: int # Has a menu bar
WINDOW_HORIZONTAL_SCROLLING_BAR: int # Allow horizontal scrollbar
WINDOW_NO_FOCUS_ON_APPEARING: int # Disable taking focus when appearing
WINDOW_NO_BRING_TO_FRONT_ON_FOCUS: int # Disable bringing to front on focus
WINDOW_ALWAYS_VERTICAL_SCROLLBAR: int # Always show vertical scrollbar
WINDOW_ALWAYS_HORIZONTAL_SCROLLBAR: int # Always show horizontal scrollbar
WINDOW_NO_NAV_INPUTS: int # No gamepad/keyboard navigation
WINDOW_NO_NAV_FOCUS: int # No focusing with navigation
WINDOW_UNSAVED_DOCUMENT: int # Append '*' to title
# Convenient flag combinations
WINDOW_NO_NAV: int # NO_NAV_INPUTS | NO_NAV_FOCUS
WINDOW_NO_DECORATION: int # NO_TITLE_BAR | NO_RESIZE | NO_SCROLLBAR | NO_COLLAPSE
WINDOW_NO_INPUTS: int # NO_MOUSE_INPUTS | NO_NAV_INPUTS | NO_NAV_FOCUSConstants for controlling when window properties are applied:
NONE: int # No condition (same as ALWAYS)
ALWAYS: int # Always set the variable
ONCE: int # Set once per runtime session
FIRST_USE_EVER: int # Set if no persistently saved data
APPEARING: int # Set when appearing after being hiddenimport imgui
# Create a simple window
if imgui.begin("My Window"):
imgui.text("Hello from my window!")
if imgui.button("Click me"):
print("Button clicked!")
imgui.end()# Set up window properties before creating
imgui.set_next_window_size(400, 300, imgui.FIRST_USE_EVER)
imgui.set_next_window_position(100, 100, imgui.FIRST_USE_EVER)
# Create window with custom flags
if imgui.begin("Configured Window", True, imgui.WINDOW_NO_RESIZE | imgui.WINDOW_MENU_BAR):
imgui.text("This window has a menu bar and can't be resized")
if imgui.begin_menu_bar():
if imgui.begin_menu("File"):
if imgui.menu_item("Open"):
print("Open clicked")
imgui.end_menu()
imgui.end_menu_bar()
imgui.end()if imgui.begin("Parent Window"):
imgui.text("This is the parent window")
# Create a scrolling child region
if imgui.begin_child("scrolling", 0, 200, True):
for i in range(50):
imgui.text(f"Line {i}")
imgui.end_child()
imgui.text("Back in parent window")
imgui.end()Install with Tessl CLI
npx tessl i tessl/pypi-imgui