When I run this code, I'm expecting the "running action" notification to not be shown until the action
function is called, similar to how the "handling upload" notification is not shown until the handle_upload
function is called. I'm not sure why it works as expected with handle_upload
, but not with action
. When I upload a file, I see both notifications, "running action" and "handling upload". When I click the "Action the Data" button, I don't see any notification. Appreciate any advice/suggestions for getting the expected behavior (and better understanding how NiceGUI works).
@ui.page("/submit")
def submit():
def action_it(data: bytes) -> None:
ui.notify("running action")
def handle_upload(file: events.UploadEventArguments) -> None:
ui.notify("handling upload")
data = file.content.read()
lines = [line for line in data.splitlines() if line.strip()]
output.clear()
with output:
ui.label('Lines uploaded:')
for line in lines:
ui.label(line.decode())
ui.button("Action the Data", on_click=action_it(data))
ui.button("Cancel")
ui.upload(on_upload=handle_upload, auto_upload=True)
output = ui.column()