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.

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.

About CDB 361 Articles
Self-Employed Software Developer, Spark, Property Management, Hobby Forestry, Ex-Teacher, Engineering - Wood, Metal, Electrics & Computers. Outdoors - Walk, Cycle, Kitesurf,

Be the first to comment

Leave a Reply

Your email address will not be published.


*


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