Change Alert buttons while Alert is open

Does anyone know of anyway to change the buttons while an alert is open.

I am using a form as the content and want to remove or disable one of the buttons (the “Save” button) based on an input in the form while the alert is still open.
The idea is to prevent the user from hitting save until all data entry is valid.

1 Like

You can always disable the button with:
self.button_1.enabled = False

You can make it disappear with
self.button_1.visible = False

These lines of code can run off any trigger in the alert box, in particular, off of code that monitors the data entry.

Thanks @jonathan.falk but I should have clarified, I want to disable the Alert Buttons not any buttons in the form. White section in the image is the Alert pop up.

I cannot see how to address the alert itself while it is active.

Ah… Well, the first thing that occurs to me is to simply can the alert save button and replace it with a button on the form that looks like it but let me do some more looking.

Since typical code can wait for a return value of the alert

save_clicked = alert(content=Form1())

The alert itself (title, footer buttons) isn’t an object you have access to apart from being able to close it from within the content form like.

self.raise_event('x-close-alert')

Which would be my typical go to when I need the buttons on an alert to be dynamic

def save_button_click(self, **event_args):
  self.raise_event('x-close-alert', value=True)
1 Like

hmmm I thought this would be the case. Thanks for confirming Stu.
I think it will have to be @jonathan.falk’s solution with buttons on the form itself.
Thanks guys

1 Like