Skip to content

Commit c24fa3c

Browse files
Improve hello world example
1 parent e9279cb commit c24fa3c

File tree

1 file changed

+19
-7
lines changed
  • internal_filesystem/apps/com.example.helloworld/assets

1 file changed

+19
-7
lines changed
Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1-
import time
2-
myscreen = lv.screen_active()
1+
# START OF COPY-PASTE FROM https://sim.lvgl.io/v9.0/micropython/ports/webassembly/
32

4-
print("Hello World running!")
3+
# Initialize
54

6-
label = lv.label(myscreen)
7-
label.set_text("Hello World!")
5+
import display_driver
6+
import lvgl as lv
87

9-
while lv.screen_active() == myscreen
10-
time.sleep_ms(100)
8+
# Create a button with a label
9+
10+
scr = lv.obj()
11+
btn = lv.button(scr)
12+
btn.align(lv.ALIGN.CENTER, 0, 0)
13+
label = lv.label(btn)
14+
label.set_text('Hello World!')
15+
lv.screen_load(scr)
1116

17+
# END OF COPY-PASTE FROM https://sim.lvgl.io/v9.0/micropython/ports/webassembly/
18+
19+
# Added: wait until the user navigates away instead of stopping immediately.
20+
while lv.screen_active() == scr:
21+
import time
22+
time.sleep_ms(100)
23+
print("User navigated away from the HelloWorld app. Bye bye!")

0 commit comments

Comments
 (0)