Wat is LessonUp
Zoeken
Kanalen
Inloggen
Registreren
‹
Terug naar zoeken
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
volgende
Slide 1:
Tekstslide
Programming
Higher Education (degree)
In deze les zitten
11 slides
, met
tekstslides
.
Start les
Bewaar
Deel
Printen
Onderdelen in deze les
Welcome to Session 2
Hands-on Event-Driven Programming with Tkinter
Module Lecturer: Dr Raghav Kovvuri
Email: raghav.kovvuri@ieg.ac.uk
Slide 1 - Tekstslide
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 - Tekstslide
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 - Tekstslide
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 - Tekstslide
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 - Tekstslide
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 - Tekstslide
Advanced Event Handling
Multiple event bindings:
Exercise:
Add keyboard support to your calculator (number keys and operators)
Slide 7 - Tekstslide
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 - Tekstslide
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 - Tekstslide
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 - Tekstslide
Slide 11 - Tekstslide
Meer lessen zoals deze
WK4:Event-Driven Programming and IDE Features (Session 1)
Oktober 2024
- Les met
10 slides
Programming
Higher Education (degree)
Verken Python's Tkinter: Een Introductie voor Beginners
December 2023
- Les met
13 slides
Python lesson 3
September 2024
- Les met
20 slides
Computing
Lower Secondary (Key Stage 3)
WK5: Implementing Secure Algorithms in an IDE (Session 1)
Oktober 2024
- Les met
11 slides
Programming
Higher Education (degree)
Introduction to PHP: Building the Basics
Juli 2024
- Les met
16 slides
Building Robust Programs with Defensive Design
Juni 2023
- Les met
25 slides
WK2: Coding Standards and Hands-on Exercises (Session 2)
September 2024
- Les met
11 slides
Programming
Higher Education (degree)
Mastering Tkinter: Creating Dynamic GUIs with Labels
April 2024
- Les met
13 slides