-
Notifications
You must be signed in to change notification settings - Fork 417
Expand file tree
/
Copy path02_status_bar_mixed.py
More file actions
65 lines (50 loc) · 1.29 KB
/
Copy path02_status_bar_mixed.py
File metadata and controls
65 lines (50 loc) · 1.29 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""Step 2: draw(ui) plus retained shell features.
This example keeps draw(ui) as the content source while adding:
- space = lf.ui.PanelSpace.STATUS_BAR
- style
- height_mode
- update_interval_ms
- on_update()
"""
import lichtfeld as lf
class StatusBarMixedPanel(lf.ui.Panel):
id = "docs.status_bar_mixed"
label = "Status Bar Mixed"
space = lf.ui.PanelSpace.STATUS_BAR
order = 50
height_mode = lf.ui.PanelHeightMode.CONTENT
update_interval_ms = 140
style = """
body.status-bar-panel {
padding: 0 12dp;
}
#im-root .im-line {
align-items: center;
gap: 8dp;
}
#im-root .im-label {
color: #f3c96d;
font-size: 10dp;
font-weight: bold;
}
"""
def __init__(self):
self._progress = 0.22
self._beats = 0
def draw(self, ui):
ui.label("BUILD UP")
ui.progress_bar(self._progress, f"{int(self._progress * 100)}%")
ui.same_line()
ui.text_disabled(f"tick {self._beats:03d}")
def on_update(self, doc):
del doc
self._beats += 1
self._progress = (self._progress + 0.02) % 1.0
return True
_classes = [StatusBarMixedPanel]
def on_load():
for cls in _classes:
lf.register_class(cls)
def on_unload():
for cls in reversed(_classes):
lf.unregister_class(cls)