Custom Buttons
For complex interactions, default "Next" and "Back" buttons may not be sufficient. You can define custom buttons as shown below:
- When a button is pressed, the function runs with its value set to
True. - Since the
keyparameter is optional in the button, if it is omitted, the key in the state that is set toTruewill be the button's label. - Returning widgets advances the page automatically.
ExitButton
Use ExitButton to let users cancel or exit a form at any point. When clicked, ExitButton terminates the entire process via sys.exit(0) — no code after run() will execute.
ExitButtondoes not validate the current page - the user explicitly chose to exit.- When the user clicks
ExitButton, the process terminates immediately. Any code afterrun()will not execute. - Always pair
ExitButtonwithNextButton()so users can also proceed normally.