w3resource

Python PyQt Widgets Exercises and Solutions

Python PyQt Widgets [12 exercises with solution]

[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]

These exercises cover various aspects of working with widgets in PyQt. These include their customization, layout management, and the creation of custom widgets to enhance the user interface.

1. Write a Python program that displays the text "Hello, PyQt!" in the center of the window using PyQt.

Click me to see the sample solution

2. Write a Python program that builds an application with two buttons "Yes" and "No" using PyQt. When the user clicks a button, display a message box with the corresponding choice.

Click me to see the sample solution

3. Write a Python program to create a simple text editor using PyQt. Allow users to input and save text to a file.

Click me to see the sample solution

4. Write a Python program to create a combobox with a list of colors using PyQt. When the user selects a color from the dropdown, change the main window background color.

Click me to see the sample solution

5. Write a Python program that designs a PyQt application with a push button that changes its text and background color when clicked.

Click me to see the sample solution

6. Write a Python program that customizes the appearance of a label text color, input field background color and a push button to close the dialog using PyQt.

Click me to see the sample solution

7.Write a Python program that builds an image viewer application that displays images using PyQt. Allow users to change the image by clicking "Previous" and "Next" buttons.

Click me to see the sample solution

8. Write a Python program that implements a temperature converter app that lets users choose between Celsius and Fahrenheit using PyQt. Customize the widget appearance based on the selected unit.

Click me to see the sample solution

9. Write a Python program to create a login form that accepts username and password and validates them. Use the PyQt5 module.

Click me to see the sample solution

10. Write a Python program to create push buttons in a grid where each button represents a numeric keypad. Use PyQt module.

Click me to see the sample solution

11. Write a Python program to build a chat application that displays messages after typing a new message. Use the PyQt module.

Click me to see the sample solution

12. Write a Python program to create a custom progress bar widget that displays a progress percentage using PyQt. Create methods to set and update progress values.

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



Become a Patron!

Follow us on Facebook and Twitter for latest update.

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_widgets.php