Our button callback handler is defined at starting on line (4) and is more involved than the previous GPIOZero handler:
def pressed(gpio_pin, level, tick): # (4)
# Get current pin state for LED.
led_state = pi.read(LED_GPIO_PIN) # (5)
if led_state == 1: # (6)
# LED is on, so turn it off.
pi.write(LED_GPIO_PIN, 0) # 0 = Pin Low = Led Off
print("Button pressed: Led is off")
else: # 0
# LED is off, so turn it on.
pi.write(LED_GPIO_PIN, 1) # 1 = Pin High = Led On
print("Button pressed: Led is on")
# Register button handler.
pi.callback(BUTTON_GPIO_PIN, pigpio.FALLING_EDGE, pressed) # (7)
Notice the signature of pressed(gpio_pin, level, tick). Our previous GPIOZero version has no parameters while PiGPIO has three mandatory parameters. Our simple one-button example does not use these parameters; however, for completeness...