Custom Buttons
For complex interactions, default "Next" and "Back" buttons may not be sufficient. You can define custom buttons as shown below:
from abstra.forms import run, TextInput, Button
import my_api
def deal_decision(state):
if state.get("Approve"):
my_api.approve(state["deal_id"])
return
if state.get("Reject"):
my_api.reject(state["deal_id"])
return
return [
TextInput(label="Enter deal ID", key="deal_id")
],
[Button("Approve"), Button("Reject")]
state = run([deal_decision])
info
- When a button is pressed, the function runs with its value set to
True
. - Returning widgets advances the page automatically.