-
QuestionI can't seem to find a way to get an example such as this to work - I am wondering if it is something related a .. "gap" .. between initialization and render state in the browser? from nicegui import ui
# Define a function to handle client connections
def on_client_connect(client):
# Set the value of the widget when a client connects
my_widget.set_value("Welcome!")
# Create a widget, for example, a label
my_widget = ui.label("Initial Value")
# Register the on_connect event handler
ui.context.client.on_connect(on_client_connect)
# Run the NiceGUI application
ui.run(port=8500) |
Beta Was this translation helpful? Give feedback.
Answered by
rodja
Oct 17, 2024
Replies: 1 comment 1 reply
-
There are quite a few bugs in your code. Try def on_client_connect():
with ui.context.client:
my_widget.text = "Welcome!"
my_widget = ui.label("Initial Value")
app.on_connect(on_client_connect) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
xaptronic
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are quite a few bugs in your code. Try