C.10 Events
onclick(function, button=1, add=None) Register a function to a mouse click so that function is called whenever the user presses the button. Note that function must accept two parameters that will give the position of the mouse when the button is clicked. button identifies the mouse button, with 1 being the left button. If add is True, a new callback will be added; otherwise, the function will replace the previous callback. If None is passed as the function parameter, the callback is canceled.
onkey(function, key) Register a function to a key press. function must be defined with no parameters. key is a string representing a key on the keyboard. If None is passed as the function parameter, the callback is canceled.
ontimer(function, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access