-
Notifications
You must be signed in to change notification settings - Fork 362
Expand file tree
/
Copy pathnested_layout.py
More file actions
51 lines (36 loc) · 1.38 KB
/
Copy pathnested_layout.py
File metadata and controls
51 lines (36 loc) · 1.38 KB
1
2
3
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
# SPDX-FileCopyrightText: 2025 LichtFeld Studio Authors
# SPDX-License-Identifier: GPL-3.0-or-later
"""Deep nesting with state cascading and alert."""
import lichtfeld as lf
class NestedLayoutPanel(lf.ui.Panel):
label = "Nested Layout"
space = lf.ui.PanelSpace.MAIN_PANEL_TAB
order = 302
def __init__(self):
self.value = 0.5
self.threshold = 0.8
self.enabled = True
def draw(self, ui):
with ui.box() as outer:
outer.heading("Outer Box")
with outer.column() as col:
col.enabled = self.enabled
with col.split(0.4) as split:
split.label("Value")
changed, self.value = split.slider_float("##val", self.value, 0.0, 1.0)
with col.row() as row:
row.button("Reset")
row.button("Apply")
with col.column() as alert_col:
alert_col.alert = self.value > self.threshold
changed, self.threshold = alert_col.slider_float(
"Threshold", self.threshold, 0.0, 1.0
)
alert_col.label("Normal text after alert")
_classes = [NestedLayoutPanel]
def on_load():
for cls in _classes:
lf.register_class(cls)
def on_unload():
for cls in reversed(_classes):
lf.unregister_class(cls)