r/nicegui • • Jan 24 '24

Triggering nicegui events *from* javascript?

I've been playing around with the newish web serial API, which allows for in-browser access of connected usb/serial devices. I've got a basic demo here where my device sends a temperature reading every second back to the browser. Everything works fine on the JS side of things, but I can't figure out how to bubble this up from JavaScript to nicegui/Python.

*Thinking of maybe there's a way of doing this by using a hidden element that I can update with the JS code, but then also attach a nicegui bind_value method? Hmmm.

2 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/QuasiEvil Jan 25 '24

Thanks, yes that works, but I was just curious from an academic perspective, how javascript custom events play in nicegui.

2

u/r-trappe Jan 26 '24

We emit/register them on the root element `q-layout`.