What is LessonUp
Search
Channels
Log in
Register
‹
Return to search
WK4: Hands-on Event-Driven Programming with Tkinter
Welcome to Session 2
Hands-on Event-Driven Programming with Tkinter
Module Lecturer: Dr Raghav Kovvuri
Email: raghav.kovvuri@ieg.ac.uk
1 / 11
next
Slide 1:
Slide
Programming
Higher Education (degree)
This lesson contains
11 slides
, with
text slides
.
Start lesson
Save
Share
Print lesson
Items in this lesson
Welcome to Session 2
Hands-on Event-Driven Programming with Tkinter
Module Lecturer: Dr Raghav Kovvuri
Email: raghav.kovvuri@ieg.ac.uk
Slide 1 - Slide
Introduction to Tkinter
Tkinter:
Python's standard GUI (Graphical User Interface) package
Event-Driven Programming recap
Programs respond to events (e.g., button clicks, key presses)
Main event loop listens for and handles events
Slide 2 - Slide
Basic Tkinter Widgets
Common widgets:
Button
Label
Entry (text input)
Checkbutton
Radiobutton
Example:
Exercise:
Create a window with a label and a button
Slide 3 - Slide
Handling Events in Tkinter
Event binding:
Connect a function to a widget event
Exercise:
Modify the button to change the label text when clicked
Slide 4 - Slide
Layout Management
Tkinter geometry managers:
pack() - simple
grid() - table-like
place() - precise positioning
Grid example:
Exercise:
Create a login form with username and password fields
Slide 5 - Slide
Discussion - Event Types
Common Tkinter events:
<Button-1>:
Left mouse click
<Key>:
Any key press
<Return>:
Enter key press
<FocusIn>:
Widget gains focus
<MouseWheel>:
Mouse scroll
Question:
Can you think of other useful events for our calculator?
Slide 6 - Slide
Advanced Event Handling
Multiple event bindings:
Exercise:
Add keyboard support to your calculator (number keys and operators)
Slide 7 - Slide
Error Handling in GUI Applications
Importance of error handling in GUIs:
Prevent crashes
Provide user feedback
Example:
Implement error handling in your calculator
Slide 8 - Slide
Task:
Extending the Calculator
Implement two ideas:
Implement memory functions (M+, M-, MR, MC)
Add square root and power functions
Create a scientific calculator mode
Hands on Exercise
timer
1:00:00
Slide 9 - Slide
Recap
Key points:
Event-driven programming responds to user actions
Tkinter provides a simple way to create GUIs in Python
Proper event handling and error management are crucial
Slide 10 - Slide
Slide 11 - Slide
More lessons like this
WK4:Event-Driven Programming and IDE Features (Session 1)
October 2024
- Lesson with
10 slides
Programming
Higher Education (degree)
Python lesson 3
September 2024
- Lesson with
20 slides
Computing
Lower Secondary (Key Stage 3)
WK5: Implementing Secure Algorithms in an IDE (Session 1)
October 2024
- Lesson with
11 slides
Programming
Higher Education (degree)
Building a Computer Game with Python
October 2023
- Lesson with
26 slides
Introduction to PHP: Building the Basics
July 2024
- Lesson with
16 slides
Building Robust Programs with Defensive Design
June 2023
- Lesson with
25 slides
Mastering Tkinter: Creating Dynamic GUIs with Labels
April 2024
- Lesson with
13 slides
WK2: Coding Standards and Hands-on Exercises (Session 2)
September 2024
- Lesson with
11 slides
Programming
Higher Education (degree)