or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

drawing.mdindex.mdinput.mdintegrations.mdlayout.mdmenus.mdstyling.mdtables.mdtabs.mdwidgets.mdwindows.md

windows.mddocs/

0

# Window Management

1

2

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.

3

4

## Capabilities

5

6

### Window Creation and Control

7

8

Core functions for creating and managing windows with various properties and behaviors.

9

10

```python { .api }

11

def begin(label: str, closable: bool = False, flags: int = 0) -> bool:

12

"""Begin a new window. Returns True if window is not collapsed."""

13

14

def end() -> None:

15

"""End the current window. Must be called after begin()."""

16

17

def begin_child(label: str, width: float = 0, height: float = 0, border: bool = False, flags: int = 0) -> bool:

18

"""Begin a scrolling region (child window). Returns True if region is visible."""

19

20

def end_child() -> None:

21

"""End the current child window."""

22

```

23

24

### Window Properties and State

25

26

Functions to query and control window dimensions, position, and visibility states.

27

28

```python { .api }

29

def get_window_position() -> tuple[float, float]:

30

"""Get current window position as (x, y)."""

31

32

def get_window_size() -> tuple[float, float]:

33

"""Get current window size as (width, height)."""

34

35

def get_window_width() -> float:

36

"""Get current window width."""

37

38

def get_window_height() -> float:

39

"""Get current window height."""

40

41

def is_window_collapsed() -> bool:

42

"""Check if current window is collapsed."""

43

44

def is_window_appearing() -> bool:

45

"""Check if current window is appearing this frame."""

46

47

def is_window_hovered(flags: int = 0) -> bool:

48

"""Check if current window is hovered by mouse."""

49

50

def is_window_focused(flags: int = 0) -> bool:

51

"""Check if current window is focused."""

52

```

53

54

### Window Positioning and Sizing

55

56

Functions to programmatically control window placement and dimensions.

57

58

```python { .api }

59

def set_window_focus() -> None:

60

"""Set current window to be focused."""

61

62

def set_window_focus_labeled(label: str) -> None:

63

"""Set named window to be focused."""

64

65

def set_window_size(width: float, height: float, condition: int = ONCE) -> None:

66

"""Set current window size."""

67

68

def set_window_size_named(label: str, width: float, height: float, condition: int = ONCE) -> None:

69

"""Set named window size."""

70

71

def set_window_position(x: float, y: float, condition: int = ALWAYS) -> None:

72

"""Set current window position."""

73

74

def set_window_position_labeled(label: str, x: float, y: float, condition: int = ALWAYS) -> None:

75

"""Set named window position."""

76

77

def set_window_collapsed(collapsed: bool, condition: int = ALWAYS) -> None:

78

"""Set current window collapsed state."""

79

80

def set_window_collapsed_labeled(label: str, collapsed: bool, condition: int = ALWAYS) -> None:

81

"""Set named window collapsed state."""

82

83

def set_window_font_scale(scale: float) -> None:

84

"""Adjust per-window font scale."""

85

```

86

87

### Next Window Setup

88

89

Functions to configure properties for the next window before calling begin().

90

91

```python { .api }

92

def set_next_window_position(x: float, y: float, condition: int = ALWAYS, pivot_x: float = 0, pivot_y: float = 0) -> None:

93

"""Set next window position with optional pivot point."""

94

95

def set_next_window_size(width: float, height: float, condition: int = ALWAYS) -> None:

96

"""Set next window size."""

97

98

def set_next_window_size_constraints(size_min: tuple[float, float], size_max: tuple[float, float]) -> None:

99

"""Set next window size constraints."""

100

101

def set_next_window_content_size(width: float, height: float) -> None:

102

"""Set next window content size (with scrollbars)."""

103

104

def set_next_window_collapsed(collapsed: bool, condition: int = ALWAYS) -> None:

105

"""Set next window collapsed state."""

106

107

def set_next_window_focus() -> None:

108

"""Set next window to be focused."""

109

110

def set_next_window_bg_alpha(alpha: float) -> None:

111

"""Set next window background alpha."""

112

```

113

114

### Content Region Information

115

116

Functions to query available space within windows for proper layout calculations.

117

118

```python { .api }

119

def get_content_region_max() -> tuple[float, float]:

120

"""Get maximal content boundaries."""

121

122

def get_content_region_available() -> tuple[float, float]:

123

"""Get available content region size."""

124

125

def get_content_region_available_width() -> float:

126

"""Get available content region width."""

127

128

def get_window_content_region_min() -> tuple[float, float]:

129

"""Get minimal content boundaries."""

130

131

def get_window_content_region_max() -> tuple[float, float]:

132

"""Get maximal content boundaries."""

133

134

def get_window_content_region_width() -> float:

135

"""Get content region width."""

136

```

137

138

### Window Flags

139

140

Common window flag constants for controlling window behavior:

141

142

```python { .api }

143

# Basic window flags

144

WINDOW_NONE: int

145

WINDOW_NO_TITLE_BAR: int # Disable title-bar

146

WINDOW_NO_RESIZE: int # Disable user resizing

147

WINDOW_NO_MOVE: int # Disable user moving

148

WINDOW_NO_SCROLLBAR: int # Disable scrollbars

149

WINDOW_NO_SCROLL_WITH_MOUSE: int # Disable scroll with mouse wheel

150

WINDOW_NO_COLLAPSE: int # Disable collapsing with double-click

151

WINDOW_ALWAYS_AUTO_RESIZE: int # Resize to content every frame

152

WINDOW_NO_BACKGROUND: int # Disable background drawing

153

WINDOW_NO_SAVED_SETTINGS: int # Never load/save settings

154

WINDOW_NO_MOUSE_INPUTS: int # Disable mouse input catching

155

WINDOW_MENU_BAR: int # Has a menu bar

156

WINDOW_HORIZONTAL_SCROLLING_BAR: int # Allow horizontal scrollbar

157

WINDOW_NO_FOCUS_ON_APPEARING: int # Disable taking focus when appearing

158

WINDOW_NO_BRING_TO_FRONT_ON_FOCUS: int # Disable bringing to front on focus

159

WINDOW_ALWAYS_VERTICAL_SCROLLBAR: int # Always show vertical scrollbar

160

WINDOW_ALWAYS_HORIZONTAL_SCROLLBAR: int # Always show horizontal scrollbar

161

WINDOW_NO_NAV_INPUTS: int # No gamepad/keyboard navigation

162

WINDOW_NO_NAV_FOCUS: int # No focusing with navigation

163

WINDOW_UNSAVED_DOCUMENT: int # Append '*' to title

164

165

# Convenient flag combinations

166

WINDOW_NO_NAV: int # NO_NAV_INPUTS | NO_NAV_FOCUS

167

WINDOW_NO_DECORATION: int # NO_TITLE_BAR | NO_RESIZE | NO_SCROLLBAR | NO_COLLAPSE

168

WINDOW_NO_INPUTS: int # NO_MOUSE_INPUTS | NO_NAV_INPUTS | NO_NAV_FOCUS

169

```

170

171

### Condition Constants

172

173

Constants for controlling when window properties are applied:

174

175

```python { .api }

176

NONE: int # No condition (same as ALWAYS)

177

ALWAYS: int # Always set the variable

178

ONCE: int # Set once per runtime session

179

FIRST_USE_EVER: int # Set if no persistently saved data

180

APPEARING: int # Set when appearing after being hidden

181

```

182

183

## Usage Examples

184

185

### Basic Window Creation

186

187

```python

188

import imgui

189

190

# Create a simple window

191

if imgui.begin("My Window"):

192

imgui.text("Hello from my window!")

193

if imgui.button("Click me"):

194

print("Button clicked!")

195

imgui.end()

196

```

197

198

### Configured Window

199

200

```python

201

# Set up window properties before creating

202

imgui.set_next_window_size(400, 300, imgui.FIRST_USE_EVER)

203

imgui.set_next_window_position(100, 100, imgui.FIRST_USE_EVER)

204

205

# Create window with custom flags

206

if imgui.begin("Configured Window", True, imgui.WINDOW_NO_RESIZE | imgui.WINDOW_MENU_BAR):

207

imgui.text("This window has a menu bar and can't be resized")

208

209

if imgui.begin_menu_bar():

210

if imgui.begin_menu("File"):

211

if imgui.menu_item("Open"):

212

print("Open clicked")

213

imgui.end_menu()

214

imgui.end_menu_bar()

215

216

imgui.end()

217

```

218

219

### Child Window with Scrolling

220

221

```python

222

if imgui.begin("Parent Window"):

223

imgui.text("This is the parent window")

224

225

# Create a scrolling child region

226

if imgui.begin_child("scrolling", 0, 200, True):

227

for i in range(50):

228

imgui.text(f"Line {i}")

229

imgui.end_child()

230

231

imgui.text("Back in parent window")

232

imgui.end()

233

```