We want to display our ‘ArticleEdit’ Form when a user clicks the ‘Add an article’ button.

We’ll use Events for this.

Click on ‘Homepage’ in the App Browser to go back to your UI. Click on your ‘Add an article’ Button, and scroll to the bottom of the Properties Panel. You’ll see a list of events for the Button.

Click the blue arrows next to ‘click’.

Adding a click handler to the 'Add an article' Button from the Properties pane.

Configuring a click event handler from the Properties pane.

You will be taken to the Form Editor’s ‘Code’ view, where you’ll see an add_article_button_click method on your Form that looks like this:

def add_article_button_click(self, **event_args):
  """This method is called when the button is clicked"""

This is the Python method that runs when the ‘Add an article’ Button is clicked.

When someone clicks this button, we want to display a popup Form that users can fill out to save a new article. We do this using Alerts.

To display a simple alert, change your click handler to trigger an alert as follows:

def add_article_button_click(self, **event_args):
  # Display a popup that says 'You clicked the button'
  alert("You clicked the button")

To see it in action, click the ‘Run’ button at the top of the screen:

Location of the Run button

You’ll see your app running. Click the ‘Add an article’ button and your popup should appear!

An alert saying 'You clicked the button'.