From c24fa3cd01d5476644c5a715b4b69b5ba21e4852 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Sat, 3 May 2025 10:09:39 +0200 Subject: [PATCH] Improve hello world example --- .../com.example.helloworld/assets/hello.py | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/internal_filesystem/apps/com.example.helloworld/assets/hello.py b/internal_filesystem/apps/com.example.helloworld/assets/hello.py index f9179ec2..def11a5d 100644 --- a/internal_filesystem/apps/com.example.helloworld/assets/hello.py +++ b/internal_filesystem/apps/com.example.helloworld/assets/hello.py @@ -1,11 +1,23 @@ -import time -myscreen = lv.screen_active() +# START OF COPY-PASTE FROM https://sim.lvgl.io/v9.0/micropython/ports/webassembly/ -print("Hello World running!") +# Initialize -label = lv.label(myscreen) -label.set_text("Hello World!") +import display_driver +import lvgl as lv -while lv.screen_active() == myscreen +# Create a button with a label + +scr = lv.obj() +btn = lv.button(scr) +btn.align(lv.ALIGN.CENTER, 0, 0) +label = lv.label(btn) +label.set_text('Hello World!') +lv.screen_load(scr) + +# END OF COPY-PASTE FROM https://sim.lvgl.io/v9.0/micropython/ports/webassembly/ + +# Added: wait until the user navigates away instead of stopping immediately. +while lv.screen_active() == scr: + import time time.sleep_ms(100) - +print("User navigated away from the HelloWorld app. Bye bye!")