|
74 | 74 |
|
75 | 75 | # Another progress bar, with explicit range and fill from the right
|
76 | 76 | ranged_bar = HorizontalProgressBar(
|
77 |
| - (2, 20), |
78 |
| - (40, 8), |
79 |
| - value=40, |
80 |
| - min_value=0, |
81 |
| - max_value=100, |
82 |
| - direction=HorizontalFillDirection.RIGHT_TO_LEFT, |
| 77 | + (2, 20), (40, 8), value=40, min_value=0, max_value=100, direction = HorizontalFillDirection.RIGHT_TO_LEFT, |
83 | 78 | )
|
84 | 79 | group.insert(1, ranged_bar)
|
85 | 80 |
|
86 | 81 | # Sample thermometer from -40C to 50C, with a value of +15C
|
87 | 82 | vertical_bar = VerticalProgressBar(
|
88 |
| - (50, 4), |
89 |
| - (10, 24), |
| 83 | + (44, 4), |
| 84 | + (8, 24), |
90 | 85 | min_value=-40,
|
91 | 86 | max_value=50,
|
92 | 87 | value=15,
|
|
97 | 92 | )
|
98 | 93 | group.insert(2, vertical_bar)
|
99 | 94 |
|
| 95 | +vertical_bar2 = VerticalProgressBar( |
| 96 | + (54, 4), |
| 97 | + (8, 24), |
| 98 | + min_value=-40, |
| 99 | + max_value=50, |
| 100 | + value=15, |
| 101 | + bar_color=0x1111FF, |
| 102 | + fill_color=None, |
| 103 | + margin_size=0, |
| 104 | + outline_color=0x2222AA, |
| 105 | + direction=VerticalFillDirection.TOP_TO_BOTTOM, |
| 106 | +) |
| 107 | +group.insert(3, vertical_bar2) |
| 108 | + |
100 | 109 | # Countdown to the start of the bars demo
|
101 | 110 | countdown_bar = HorizontalProgressBar(
|
102 | 111 | (2, 2),
|
|
112 | 121 |
|
113 | 122 | countdown_end_color = 0xFF1111
|
114 | 123 |
|
115 |
| -group.insert(3, countdown_bar) |
| 124 | +group.insert(4, countdown_bar) |
116 | 125 | # group.insert(0, countdown_bar)
|
117 | 126 |
|
118 | 127 | print("Progress bars added. Starting demo...")
|
|
148 | 157 | ranged_bar.value = progress_bar_value
|
149 | 158 | progress_bar_value += progress_bar_incr
|
150 | 159 |
|
| 160 | + |
| 161 | + if not (button1.value and button2.value): |
| 162 | + |
| 163 | + if not button1.value: # "UP" button pushed |
| 164 | + print("UP button pressed. Increasing vertical bars by 3") |
| 165 | + vertical_bar.value = min(vertical_bar.maximum, vertical_bar.value + 3) |
| 166 | + vertical_bar2.value = min(vertical_bar2.maximum, vertical_bar2.value + 3) |
| 167 | + |
| 168 | + if not button2.value: # "DOWN" button pushed |
| 169 | + print("DOWN button pressed. Decreasing vertical bars by 3") |
| 170 | + vertical_bar.value = max(vertical_bar.minimum, vertical_bar.value - 3) |
| 171 | + vertical_bar2.value = max(vertical_bar2.minimum , vertical_bar2.value - 3) |
| 172 | + |
| 173 | + |
151 | 174 | if progress_bar_value > progress_bar.maximum:
|
152 | 175 | progress_bar_value = progress_bar.maximum
|
153 | 176 | progress_bar_incr *= -1
|
|
156 | 179 | progress_bar_value = progress_bar.minimum
|
157 | 180 | progress_bar_incr *= -1
|
158 | 181 |
|
159 |
| - # button_pressed = False |
160 |
| - # while False == button_pressed: |
161 |
| - # button_pressed = button_pressed or not (button1.value and button2.value) |
162 |
| - # time.sleep(0.1) |
163 |
| - |
164 |
| - # print("Step") |
165 |
| - button_pressed = False |
166 | 182 | time.sleep(0.5)
|
0 commit comments