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.
Click me to see the sample solution
2. Write a Python program that captures and displays mouse events like clicks and movements using PyQt5.
Click me to see the sample solution
3. Write a Python program to build a PyQt application that responds to keyboard events such as key presses and releases.
Click me to see the sample solution
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.
Click me to see the sample solution
5. Write a Python program that creates a custom widget in PyQt and implements a custom keyboard shortcuts by overriding the key press method.
Click me to see the sample solution
6. Write a Python program that allows users to drag and drop two labels within a window using PyQt.
Click me to see the sample solution
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.
Click me to see the sample solution
8. Write a Python program to build a PyQt5 application that allows users to draw shapes and freehand lines on a canvas.
Click me to see the sample solution
9. Write a Python program that displays an image and allows users to annotate it with text.
Click me to see the sample solution
10. Write a Python program to design a PyQt5 digital clock widget that updates the time every second.
Click me to see the sample solution
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
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/python-exercises/pyqt/pyqt_event_handling.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics