Amity Institute of Information Technology
Event and GUI Programming
Dr. Rajiv Pandey,
Senior Member IEEE
Amity University Uttar Pradesh,
Lucknow Campus,
Amity Institute of Information Technology
• In computer programming, event-driven
programming is a programming paradigm in which
the flow of the program is determined by events
such as user actions (mouse clicks, key presses),
sensor outputs, or message passing from other
programs or threads. Event-driven programming is
the dominant paradigm used in graphical user
interfaces and other applications (e.g., JavaScript
web applications) that are centered on performing
certain actions in response to user input.
2
Amity Institute of Information Technology
3
Amity Institute of Information Technology
Advantages of Event-Driven Programming
• Flexibility
• Suitability for Graphical Interfaces
• Simplicity of Programming
• Easy to Find Natural Dividing Lines
• Simple and Understandable
• Allows for more Interactive Programs
• Using Hardware Interrupts
• Allows sensors and other hardware
4
Amity Institute of Information Technology
Disadvantages
• event-driven programming is often more complex and
cumbersome than batch programming.
• The flow of the program is usually less logical and obvious
• Errors can be more difficult to spot than with simpler,
procedural programs.
• Programs with complex GUIs may be slower to load and run
than simpler programs particularly if RAM is insufficient.
• Possible tight coupling between the event schema and the
consumers of the schema.
5
Amity Institute of Information Technology
Python Event-Driven programming
• flow of a program depends upon the events, and
programming which focuses on events is called
Event-Driven programming.
• The programming model following the concept of
Event-Driven programming is called the
Asynchronous model.
• The working of Event-Driven programming depends
upon the events happening in a program.
6
Amity Institute of Information Technology
Asyncio- Python Event-Driven
programming module
• Asyncio module provides a very good
infrastructure for writing concurrent code
as single-threaded using the coroutines in
the program.
7
Amity Institute of Information Technology
Different concepts used while doing
event-driven programming:
• The event loop
• Futures
• Coroutines
• @asyncio.coroutine decorator
• Tasks
• Transports
• and Protocols
8
Amity Institute of Information Technology
Reference
• https://www.javatpoint.com/python-event-driven-programming
• Ananconda
• Chapter 4 - Introduction to Problem Solving – NCERT, https://ncert.nic.in
• W3C
• https://www.w3schools.com/python/python_lists_remove.asp
• https://www.tutorialsteacher.com/python/python-list