CatpileDocs
ExamplesInteractive Button

Learn events with parameters, conditions, loops, and functions.

Step 11. Button Click Counter1 / 6
python
on loaded:
clicks = 0
settext("label", "Clicked 0 times")
 
on pressed("incrementBtn"):
inc(clicks, 1)
settext("label", "Clicked {clicks} times")

What happens:

  • Page loads: counter starts at 0, label shows "Clicked 0 times"
  • Button pressed: counter increments, label updates

Key concepts:

  • on pressed("btnId") — event triggered by clicking a specific UI element
  • inc(var, amount) — increments a variable
  • settext("element", "text") — updates a UI element's text