Controls & panels¶
Control
¶
Binds a GUI widget to a filter keyword argument.
The widget type is inferred from the type of value_default and the
presence of value_range:
bool-> checkbox (value_rangemust be None)int/floatwith a 2-elementvalue_range-> sliderint/floatwithoutvalue_range-> free numeric parameterstrwith a list of choices asvalue_range-> dropdownstrwithoutvalue_range-> free text prompt
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value_default
|
Union[int, float, bool, str]
|
Initial value; its type selects the widget (int, float, bool or str). |
required |
value_range
|
Optional[List[Union[int, float, str]]]
|
|
None
|
name
|
Optional[str]
|
Label displayed next to the widget. Auto-generated if omitted. |
None
|
step
|
Optional[Union[int, float]]
|
Slider increment. Defaults to 1 for int sliders and 1/100 of the range for float sliders. |
None
|
filter_to_connect
|
Optional[FilterCore]
|
Filter to connect immediately (requires
|
None
|
parameter_name_to_connect
|
Optional[str]
|
Keyword argument of the connected filter. |
None
|
icons
|
Optional[List]
|
Icon image paths (one per choice) for string dropdowns. |
None
|
group
|
Optional[Union[str, 'Panel']]
|
|
None
|
tooltip
|
Optional[str]
|
Hover text displayed on the widget. |
None
|
Example
@interactive(
gain=Control(1.0, [0.0, 3.0]), # float slider
flip=Control(False), # checkbox
mode=Control("dark", ["dark", "light"]), # dropdown
)
def my_filter(img, gain=1.0, flip=False, mode="dark"):
...
Source code in src/interactive_pipe/headless/control.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
CircularControl
¶
Bases: Control
Circular (dial) variant of a numeric slider.
Behaves like a numeric Control but is rendered as a rotary dial.
With modulo=True the value wraps around at the value_range
bounds instead of saturating (useful for angles).
Source code in src/interactive_pipe/headless/control.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
TextPrompt
¶
Bases: Control
Free-text entry box bound to a string keyword argument.
Unlike a string Control with a value_range (a dropdown of fixed
choices), a TextPrompt accepts arbitrary text typed by the user.
Source code in src/interactive_pipe/headless/control.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
TimeControl
¶
Bases: Control
Auto-incrementing time control for animations.
Starts at 0.0 and increments automatically. Press 'p' to pause/resume.
Note
Only supported on Qt backend. Falls back to a regular slider on other backends (tooltip/group params are only relevant in that fallback case).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update_interval_ms
|
int
|
Interval between updates in milliseconds (default: 1000). |
1000
|
pause_resume_key
|
str
|
Key to pause/resume (default: "p"). |
'p'
|
Example
@interactive(time=TimeControl(update_interval_ms=50))
def animate(time=0.0):
return time
Source code in src/interactive_pipe/headless/control.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | |
__init__
¶
__init__(name: Optional[str] = None, update_interval_ms: int = 1000, pause_resume_key: str = 'p', filter_to_connect: Optional[FilterCore] = None, parameter_name_to_connect: Optional[str] = None, group: Optional[Union[str, Panel]] = None, tooltip: Optional[str] = None) -> None
Time control. Start at 0.0. Time can be paused/resumed
Source code in src/interactive_pipe/headless/control.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | |
KeyboardControl
¶
Bases: Control
Control driven by keyboard keys instead of a slider widget.
Pressing keydown decreases the value by step (or moves to the
previous choice for a string control); keyup increases it. A bool
control toggles on each keydown press. Special keys such as arrows,
page up/down, spacebar and F1-F12 are supported (see
SPECIAL_KEYS_LIST); other keys are single characters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value_default
|
Union[int, float, bool, str]
|
Initial value; its type selects the behavior (int, float, bool or str). |
required |
value_range
|
Optional[List[Union[int, float, str]]]
|
|
None
|
keydown
|
Optional[str]
|
Key that decreases the value / toggles a bool. |
None
|
keyup
|
Optional[str]
|
Key that increases the value. Omit for a toggle-only binding. |
None
|
modulo
|
bool
|
When True, the value wraps around at the range bounds instead of saturating. |
False
|
name
|
Optional[str]
|
Label of the control. Auto-generated if omitted. |
None
|
step
|
Optional[Union[int, float]]
|
Increment applied on each key press (same defaults as
|
None
|
filter_to_connect
|
Optional[FilterCore]
|
Filter to connect immediately (requires
|
None
|
parameter_name_to_connect
|
Optional[str]
|
Keyword argument of the connected filter. |
None
|
group
|
Optional[Union[str, Panel]]
|
|
None
|
Example
@interactive(
gain=KeyboardControl(1.0, [0.0, 3.0], keydown="g", keyup="h")
)
def amplify(img, gain=1.0):
return gain * img
Source code in src/interactive_pipe/headless/keyboard.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
Panel
¶
Panel for organizing controls into groups with optional nesting and grid layouts.
Panels can contain: - Controls (assigned via Control(..., group=panel) or Control(..., group="name")) - Other Panels (nested hierarchy) - Grid layouts (via list of lists)
Example
# Simple panel
text_panel = Panel("Text Settings")
# Collapsible panel
color_panel = Panel("Colors", collapsible=True, collapsed=False)
# Detached panel (Qt backend only - opens in separate window)
tools_panel = Panel("Tools", detached=True, detached_size=(400, 600))
# Panel with position (left, right, top, or bottom)
left_panel = Panel("Tools", position="left")
right_panel = Panel("Settings", position="right")
# Nested panels with grid layout
main_panel = Panel("Main").add_elements([
[text_panel, color_panel], # Row 1: side by side
[effects_panel], # Row 2: full width
])
Source code in src/interactive_pipe/headless/panel.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
__init__
¶
__init__(name: Optional[str] = None, collapsible: bool = False, collapsed: bool = False, detached: bool = False, detached_size: Optional[tuple] = None, position: Optional[str] = None) -> None
Initialize a Panel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Optional[str]
|
Display name for the panel (shown in group box title) |
None
|
collapsible
|
bool
|
Whether the panel can be collapsed/expanded |
False
|
collapsed
|
bool
|
Initial collapsed state (only used if collapsible=True) |
False
|
detached
|
bool
|
Whether to render panel in a separate window (Qt backend only) |
False
|
detached_size
|
Optional[tuple]
|
Optional (width, height) tuple for detached window size |
None
|
position
|
Optional[str]
|
Position relative to images - "left", "right", "top", "bottom", or None (defaults to "bottom") |
None
|
Source code in src/interactive_pipe/headless/panel.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
add_elements
¶
add_elements(elements: Union[List[Panel], List[List[Panel]]]) -> Panel
Add child panels with optional grid layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elements
|
Union[List[Panel], List[List[Panel]]]
|
Can be: - List of Panels: [panel1, panel2] - vertical stack - List of lists: [[panel1, panel2], [panel3]] - grid layout |
required |
Returns:
| Type | Description |
|---|---|
Panel
|
self for method chaining |
Example
main_panel.add_elements([
[text_panel, color_panel], # Row 1
[effects_panel], # Row 2
])
Source code in src/interactive_pipe/headless/panel.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
__eq__
¶
__eq__(other) -> bool
Panels are equal if they're the same object (for deduplication).
Source code in src/interactive_pipe/headless/panel.py
132 133 134 | |
__hash__
¶
__hash__() -> int
Use object id for hashing (for set/dict usage).
Source code in src/interactive_pipe/headless/panel.py
136 137 138 | |
get_root
¶
get_root() -> Panel
Get the root panel in the hierarchy (walks up parent chain).
Source code in src/interactive_pipe/headless/panel.py
140 141 142 143 144 145 | |