Courier Extension 1: Event Driven Programming
3. Defining the Callback
Here’s the definition of the test_line function that is called by the button’s on_click() event:
def test_line(_):
output.clear_output() # [1]
with output: # [3]
test_line_follower() # [2]
This type of functions, that gets called when an event such as a button click happens, is referred to as a callback function.
This tells the robot to [comment #1] clear the output widget [ comment #2] run the test_line_follower()
test function that you wrote and [comment #3] direct any output generated by your test function to the output widget. In this instance, it displays output messages directly under the button panel.
For speed and convenience, we have followed exactly the same process to link all the other clickable buttons to the relevant functions in your template notebook for you.