Alert2 button return values

Hi Aaron,

alert2 and input_box do not manage button icons (mmmh… that would be a nice improvement :thinking:).

If you need this level of customization, then (currently) alert2 is not the right tool. You can create a little form and put it inside the standard alert.


Your snippet cannot return None because the alert2 function doesn’t have the content or the footer_buttons arguments. And even if you tried with the correct argument names, it would crash because it’s expecting a list of strings in buttons.

alert2 creates the Button components for you, and it only manages buttons with text, not with an icon. If you want to get either 'Yes' or 'No' as an asnwer, you could do something like this:

alert2('my_question', buttons=['Yes', 'No'], dismissible=False)

Since alert2 uses a RichText component, you can use images in the markdown, and you may be able to get the click events on them:

alert2('Here is an image in the alert:\n![Anvil](https://anvil.works/ide/img/ANVIL-Logo-no-tagline-no-name.svg)')

The alert2 function is a simplified version of the input_box one. The input_box allows you to use checkboxes. You can see how to do that by clicking on the “Input box with and without prompt” button on the InputBox example app, but it still doesn’t manage icons.


PS
Please create new posts with links to old ones rather than reviving old posts that already have an answer. :slight_smile: