Qu'est-ce que LessonUp
Rechercher
Canaux
Connectez-vous
S'inscrire
‹
Revenir à la recherche
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
suivant
Slide 1:
Diapositive
Programming
Higher Education (degree)
Cette leçon contient
11 diapositives
, avec
diapositives de texte
.
Commencer la leçon
Partager
Imprimer la leçon
Éléments de cette leçon
Welcome to Session 2
Hands-on Event-Driven Programming with Tkinter
Module Lecturer: Dr Raghav Kovvuri
Email: raghav.kovvuri@ieg.ac.uk
Slide 1 - Diapositive
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 - Diapositive
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 - Diapositive
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 - Diapositive
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 - Diapositive
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 - Diapositive
Advanced Event Handling
Multiple event bindings:
Exercise:
Add keyboard support to your calculator (number keys and operators)
Slide 7 - Diapositive
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 - Diapositive
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 - Diapositive
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 - Diapositive
Slide 11 - Diapositive
Plus de leçons comme celle-ci
WK4:Event-Driven Programming and IDE Features (Session 1)
Octobre 2024
- Leçon avec
10 diapositives
Programming
Higher Education (degree)
Python lesson 3
Septembre 2024
- Leçon avec
20 diapositives
Computing
Lower Secondary (Key Stage 3)
Building a Computer Game with Python
Octobre 2023
- Leçon avec
26 diapositives
WK5: Implementing Secure Algorithms in an IDE (Session 1)
Octobre 2024
- Leçon avec
11 diapositives
Programming
Higher Education (degree)
Building Robust Programs with Defensive Design
Juin 2023
- Leçon avec
25 diapositives
Introduction to PHP: Building the Basics
Juillet 2024
- Leçon avec
16 diapositives
WK2: Coding Standards and Hands-on Exercises (Session 2)
Septembre 2024
- Leçon avec
11 diapositives
Programming
Higher Education (degree)
WK2: Coding Standards and Hands-on Exercises (Session 2)
Septembre 2024
- Leçon avec
11 diapositives
Programming
Higher Education (degree)