collapsible
sleap_nn.config_generator.tui.widgets.collapsible
¶
Collapsible section widget.
Provides expandable/collapsible content sections with header toggle.
Classes:
| Name | Description |
|---|---|
Collapsible |
Collapsible section with expandable content. |
CollapsibleGroup |
Group of collapsible sections with optional accordion behavior. |
ToggleSection |
Toggle-enabled section with switch control. |
Collapsible
¶
Bases: Widget
Collapsible section with expandable content.
A container that can be expanded or collapsed by clicking its header. Useful for organizing complex forms into logical sections.
Attributes:
| Name | Type | Description |
|---|---|---|
expanded |
reactive[bool]
|
Whether the content is currently visible. |
title |
reactive[bool]
|
The header text. |
Classes:
| Name | Description |
|---|---|
Toggled |
Posted when the collapsible is expanded or collapsed. |
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the collapsible section. |
add_content |
Add widgets to the collapsible content. |
collapse |
Collapse the content. |
compose |
Compose the collapsible layout. |
compose_add_child |
Compose a child into this widget. |
expand |
Expand the content. |
on_click |
Handle clicks on the header to toggle. |
toggle |
Toggle the expanded state. |
Source code in sleap_nn/config_generator/tui/widgets/collapsible.py
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 | |
Toggled
¶
Bases: Message
Posted when the collapsible is expanded or collapsed.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize with collapsible widget and state. |
Attributes:
| Name | Type | Description |
|---|---|---|
control |
Collapsible
|
Return the collapsible widget that sent this message. |
Source code in sleap_nn/config_generator/tui/widgets/collapsible.py
__init__(title='Section', collapsed=False, id=None, classes=None)
¶
Initialize the collapsible section.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Header text. |
'Section'
|
collapsed
|
bool
|
Initial collapsed state (expanded if False). |
False
|
id
|
Optional[str]
|
Widget ID. |
None
|
classes
|
Optional[str]
|
CSS classes. |
None
|
Source code in sleap_nn/config_generator/tui/widgets/collapsible.py
add_content(*widgets)
¶
Add widgets to the collapsible content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
widgets
|
Widget
|
Widgets to add as content. |
()
|
collapse()
¶
compose()
¶
Compose the collapsible layout.
Source code in sleap_nn/config_generator/tui/widgets/collapsible.py
compose_add_child(widget)
¶
expand()
¶
on_click(event)
async
¶
Handle clicks on the header to toggle.
Source code in sleap_nn/config_generator/tui/widgets/collapsible.py
CollapsibleGroup
¶
Bases: Widget
Group of collapsible sections with optional accordion behavior.
Can be configured so that only one section is expanded at a time (accordion mode) or allow multiple sections to be open.
Attributes:
| Name | Type | Description |
|---|---|---|
accordion |
If True, only one section can be expanded at a time. |
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the collapsible group. |
handle_section_toggle |
Handle section toggle events for accordion behavior. |
Source code in sleap_nn/config_generator/tui/widgets/collapsible.py
__init__(accordion=False, id=None, classes=None)
¶
Initialize the collapsible group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
accordion
|
bool
|
If True, only one section can be open at a time. |
False
|
id
|
Optional[str]
|
Widget ID. |
None
|
classes
|
Optional[str]
|
CSS classes. |
None
|
Source code in sleap_nn/config_generator/tui/widgets/collapsible.py
handle_section_toggle(event)
¶
Handle section toggle events for accordion behavior.
Source code in sleap_nn/config_generator/tui/widgets/collapsible.py
ToggleSection
¶
Bases: Widget
Toggle-enabled section with switch control.
A section that can be enabled/disabled with a switch, with the content hidden when disabled.
Classes:
| Name | Description |
|---|---|
Toggled |
Posted when the section is enabled/disabled. |
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the toggle section. |
add_content |
Add widgets to the section content. |
compose |
Compose the toggle section layout. |
handle_switch_change |
Handle switch toggle. |
set_enabled |
Programmatically set enabled state. |
Source code in sleap_nn/config_generator/tui/widgets/collapsible.py
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 271 272 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 308 309 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 340 341 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 | |
Toggled
¶
Bases: Message
Posted when the section is enabled/disabled.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize with toggle section widget and state. |
Attributes:
| Name | Type | Description |
|---|---|---|
control |
ToggleSection
|
Return the toggle section widget that sent this message. |
Source code in sleap_nn/config_generator/tui/widgets/collapsible.py
__init__(title='Section', enabled=False, description='', id=None, classes=None)
¶
Initialize the toggle section.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Header text. |
'Section'
|
enabled
|
bool
|
Initial enabled state. |
False
|
description
|
str
|
Optional description text. |
''
|
id
|
Optional[str]
|
Widget ID. |
None
|
classes
|
Optional[str]
|
CSS classes. |
None
|
Source code in sleap_nn/config_generator/tui/widgets/collapsible.py
add_content(*widgets)
¶
Add widgets to the section content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
widgets
|
Widget
|
Widgets to add. |
()
|
compose()
¶
Compose the toggle section layout.
Source code in sleap_nn/config_generator/tui/widgets/collapsible.py
handle_switch_change(event)
¶
Handle switch toggle.
Source code in sleap_nn/config_generator/tui/widgets/collapsible.py
set_enabled(enabled)
¶
Programmatically set enabled state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
New enabled state. |
required |