Tkinter Events

Tkinter employs a type of programming called Event-Driven which means that the program runs in a endless loop waiting for things (events) to happen.  In order for the program to respond to these events it needs to know what to listen for.  

We bind events to methods which tells the computer that in the event of that happening do this.  There are many events that can be listened for and they are explained here and here.


The code above bind an s key press event to the say hello method.

def sayHello(event):
 print "hello"

Note how the method has an event parameter even though we have not set any parameters in the bind.  This is because the event is automatically sent in the method call.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.