I built a taipy webapp to show several models. While toggling between different models, it takes some time to recalculate. If, while recalculating, you start clicking other buttons, the webapp sometimes gets stuck.
To avoid this, I added a notification (via the notify() function) which warns the user of the webapp not to click elsewhere while the app is recalculating.
My problem is now that it seems the duration that the notification is shown is a fixed time (in ms). Is it possible to make this duration dependent on the recalculating time (=so for the same time as the small circle in the right bottom of the screen is shown)?
My second problem is the position of the notification. I didn't find any option to move it for example to the center of the screen, which would make it more visible for the user. Is there already an option to do this?
notify(state, notification_type = 'info',
message = "App is recalculating. Please wait and do not click elsewhere.",
duration = 5000)
I think what you are looking for is: hold_control and resume_control. This blocks your app with a dialog showing up with a message while a task is being done.
Here is an example:
import time
from taipy.gui import Gui
from taipy.gui import builder as tgb
from taipy.gui import hold_control, resume_control
def callback_with_hold(state):
hold_control(state, message="Waiting")
time.sleep(5)
resume_control(state)
with tgb.Page() as hold_and_resume_page:
tgb.text("# Hold and Resume control", mode="md")
tgb.button("Trigger callback!", on_action=callback_with_hold)
if __name__ == "__main__":
Gui(page=hold_and_resume_page).run(use_reloader=True, dark_mode=False, port=1234)