Python PyQt event handling - Exercises and solutions
Python PyQt Event Handling [10 exercises with solution]
[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]
In these exercises you will learn how to handle events in PyQt5, including event-driven programming, overriding event handlers, and handling paint events in order to create interactive and customized PyQt5 applications.
1. Write a Python exercise that explain the concept of event-driven programming in PyQt5.
2. Write a Python program that captures and displays mouse events like clicks and movements using PyQt5.
3. Write a Python program to build a PyQt application that responds to keyboard events such as key presses and releases.
4. Write a Python program to create a window with a custom button using PyQt. When you click the custom button, a message will be printed to the console, demonstrating the changed behavior.
5. Write a Python program that creates a custom widget in PyQt and implements a custom keyboard shortcuts by overriding the key press method.
6. Write a Python program that allows users to drag and drop two labels within a window using PyQt.
7. Write a Python program that creates a window using PyQt. The window will display the mouse coordinates, and update in real-time as you move the mouse cursor within the window.
8. Write a Python program to build a PyQt5 application that allows users to draw shapes and freehand lines on a canvas.
9. Write a Python program that displays an image and allows users to annotate it with text.
10. Write a Python program to design a PyQt5 digital clock widget that updates the time every second.
Python Code Editor:
More to Come !
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
Test your Python skills with w3resource's quiz
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join