Listening for Inputs
CS 110
1
Reminders and Announcements
Next Week
quack
3
Problem 1: Infinite Loops
4
counter = 5
while counter < 5:
print(counter)
counter = counter + 1
The loop never begins (condition starts off as False)
Problem 2: Loops that aren't
5
INPUT AND EVENTS
Expanding past just using the Python interpreter
6
Examples of Inputs
There are many different kinds of inputs, which should all be very familiar to you:�
7
Events: Ways of Dealing with User Input
Events allow programs to listen to particular events (clicks, drags, etc.) and execute parts of a program based on the input. Events have two parts:
8
setup_listener("LEFT-CLICK", do_something)
9
We use this function to set the listener up.
A function name to run when the event happens (handler) that is defined to have exactly 1 input
Setting an Event Listener on the Pop-up Window
The event to listen for (a special string specified by Python)
Options as of Week 6 (all strings) :
LEFT-CLICK RIGHT-CLICK ALT-CLICK LEFT-DRAG
Demos
lecture15/event_demos/
10