Simulator v8.1... not able to change label in function

I try using…

does not update.

simulator link…
[LVGL/MicroPython Simulator]

Your example shows “Hello 3”, as you set it in chng_txt.
Could you explain the problem?

expect see in display…
‘Hello World!’ for 1 second
‘Hello 2’ for 1 second
‘Hello 3’ for 1 second

Not just ‘Hello 3’

utime.sleep freezes and does not yield to the javascript event loop, that’s probably why the display is not refreshed on the web simulator (@embeddedt could you confirm or comment?)

To overcome this you can use LVGL timers instead of “sleep” to trigger events at specified times.

That’s correct. In general it is recommended to avoid any blocking code when using the web simulator.

Would it be too much to ask for a micropython sample as the C sample is confusing with (lv_timer_t * timer) in function and using data.
Just would like a pause for each label change.

my simulator attempt…

Here: LVGL/MicroPython Simulator

So each messages is going to be completely different in the function.
Plus how do you stop this continuing Loop?
All I want is to show consecutive labels that show for x time.
Why doesent the label update and time.sleep work, I get the blocking but can’t the label change before the sleep?

JS mustn’t block - so each function must run to completion. You can’t stop and wait in the middle.

You can call timer.set_repeat_count after creating the timer.

Because sleep does not yield to the JS event loop therefore doesn’t update the display

Theres got to be a simpler way to do a one shot one second

You can use generators to simulate that (example)

I hate to beat a dead horse…
but why won’t lv.refr_now(None)
which is to force a screen refresh immediately,
not working before the blocking sleep?

What specifically is the difference between the esp32 port and the JavaScript port

scr = lv.obj()
btn = lv.btn(scr)
btn.align(lv.ALIGN.CENTER, 0, 0)
label = lv.label(btn)
label.set_text('Hello World!')

label.set_text('Hello 1')

label.set_text('Hello 2')

label.set_text('Hello 3')

This works for the esp32 port

You can’t block the main thread in JavaScript like you can on a native platform. If you do, rerendering usually stops. This is a limitation of browsers.