Wat is LessonUp
Zoeken
Kanalen
Inloggen
Registreren
‹
Terug naar zoeken
WK4:Event-Driven Programming and IDE Features (Session 1)
Welcome to Week 4
Event-Driven Programming and IDE Features
Module Lecturer: Dr Raghav Kovvuri
Email: raghav.kovvuri@ieg.ac.uk
1 / 10
volgende
Slide 1:
Tekstslide
Programming
Higher Education (degree)
In deze les zitten
10 slides
, met
tekstslides
.
Start les
Bewaar
Deel
Printen
Onderdelen in deze les
Welcome to Week 4
Event-Driven Programming and IDE Features
Module Lecturer: Dr Raghav Kovvuri
Email: raghav.kovvuri@ieg.ac.uk
Slide 1 - Tekstslide
Introduction
Definition:
A programming paradigm where the flow of the program is determined by events
Events:
User actions, sensor outputs, messages from other programs
Key Components
Event Sources (e.g., UI elements, timers, network)
Event Handlers (functions that respond to events)
Event Loop (main program loop that listens for events)
Contrast with Sequential Programming:
Sequential:
Predetermined order of execution
Event-Driven:
Reactive, based on external inputs
Slide 2 - Tekstslide
Advantages of EDP
Scalability
Responsiveness
Modularity
Resource Efficiency
Real-world Modeling
Idle until events occur, conserving system resources
Well-suited for GUI applications and I/O-bound programs
Naturally models real-world interactions and processes
Intuitive for developing simulations and interactive systems
Quickly reacts to user inputs and system events
Enhances user experience in interactive applications
Easily handles multiple input sources
Adaptable to complex user interfaces and multi-threaded environments
Event handlers can be developed and maintained separately
Facilitates parallel development in large projects
Slide 3 - Tekstslide
Example (Python & Tkinter) (1)
Basic Event-Driven Programming
tk.Tk():
Creates the main window
tk.Button():
Creates a button widget
command=button_click:
Associates the button click event with the handler
root.mainloop():
Starts the event loop
Key Concept:
The program waits for user interaction rather than executing sequentially
Slide 4 - Tekstslide
Objects as Event Handlers:
Methods of a class serve as event handlers
Encapsulates behavior associated with events
State Management:
Object's state can change in response to events
Provides a natural way to model complex systems
Example (Python & Tkinter) (2)
Objects as Event Sources:
UI elements (buttons, text fields) as objects
Each object can generate specific events
Combining OOP and Event-Driven Concepts:
Benefits:
Improved code organization
Easier state management
Enhanced reusability and maintainability
Slide 5 - Tekstslide
Example: Simple Calculator GUI
Download
WK4_EDP_Calculator.py
from Canvas and try to understand the Code
Key Points:
Class-based structure for organization
Event handlers (click method) respond to button presses
GUI layout managed within the class
Did you notice any issue with in the Output?
Slide 6 - Tekstslide
Hands on Exercise
Task:
add a reset input button to the calculator. This button should clear the current input and reset the calculator to its initial state.
timer
30:00
Slide 7 - Tekstslide
IDE Features
Setup and learn basics of VS Code
Using extensions in VS Code
Debugging
Version Control in VS Code
Version Control in VS Code
Version Control in VS Code
Version Control in VS Code
Version Control in VS Code
https://code.visualstudio.com/docs/getstarted/introvideos
For Introductory Videos Visit
timer
30:00
Slide 8 - Tekstslide
Conclusion
We've evolved our OOP calculator to use event-driven programming
Core OOP principles remain the same
Event-driven approach makes our program more interactive
This is how most modern GUI applications work!
Additional Resources
Tkinter documentation:
https://docs.python.org/3/library/tkinter.html
Real Python's Tkinter tutorial:
https://realpython.com/python-gui-tkinter/
VS Code Python tutorial:
https://code.visualstudio.com/docs/python/python-tutorial
Slide 9 - Tekstslide
Slide 10 - Tekstslide
Meer lessen zoals deze
WK4: Hands-on Event-Driven Programming with Tkinter
Oktober 2024
- Les met
11 slides
Programming
Higher Education (degree)
Building Robust Programs with Defensive Design
Juni 2023
- Les met
25 slides
Introduction to Programming Constructs: Creating a Computer Game with Python
Augustus 2024
- Les met
23 slides
Mathematics
Further Education (Key Stage 5)
Fundament indeling C# Domein J / D
Maart 2021
- Les met
30 slides
Informatica
Middelbare school
vwo
Leerjaar 5
11 - Binary search
April 2024
- Les met
21 slides
Computing
Upper Secondary (Key Stage 4)
GCSE
Python lesson 3
September 2023
- Les met
14 slides
Computing
Lower Secondary (Key Stage 3)
Python lesson 3
Maart 2024
- Les met
14 slides
Computing
Lower Secondary (Key Stage 3)
Y8 Python
Juni 2022
- Les met
38 slides
Computing
Lower Secondary (Key Stage 3)