Is it possible to change the text in a notification?
I was thinking about something like this:
with Notification('Step 1') as n:
do_step_1()
n.text = 'Step 2'
do_step_2()
n.text = 'Step 3'
do_step_3()
Is it possible to change the text in a notification?
I was thinking about something like this:
with Notification('Step 1') as n:
do_step_1()
n.text = 'Step 2'
do_step_2()
n.text = 'Step 3'
do_step_3()
I don’t know if this can be done but you could do it with an alert with a label as the content and then address the label directly
The Notification doesn’t allow to use a component, the alert does, but it will stay there and would require me to create a custom form with the code to… It has to be easier.
I ended up using JQuery. Here is what I did:
# import JQuery
from anvil.js.window import jQuery as _S
# disable all the buttons, otherwise the user could interact with the
# form while the notification is visible
self.button_x.enabled = False
# show the notification
self.notification = Notification('Hello', title='Title', timeout=0)
self.notification.show()
# hide the x button to prevent the user from closing the notification
_S('[role="alert"] [type="button"]').hide()
# store the notification text in a form attribute
self.notification_text = _S('[role="alert"] [data-notify="message"]')
# change the text, it works in the same function or in a tick event of
# a timer because it's a form attribute
self.notification_text.text('World')
# hide the notification and re-enable the buttons
self.notification.hide()
self.button_x.enabled = True