SLC S21W1 || Creating Dynamic Interfaces with Python and Qt5

Assalamualaikum my fellows I hope you will be fine by the grace of Allah. Today I am going to participate in the steemit learning challenge season 21 week 1 by @kouba01 under the umbrella of steemit team. It is about Creating Dynamic Interfaces with Python and Qt5. Let us start exploring this week's teaching course.


image.png

Develop detailed documentation to guide a user through the installation of the working environment including Thonny and Qt5 Designer. This guide should be structured and contain the precise steps you followed to install these tools, so that a beginner can reproduce the installation without difficulty.

It is really interesting course because I am getting the chance to explore it with a designer and Python. I am going to explain the installation of the complete working environment including Thonny and Qt5 designer.

First of all I want to tell that Qt5 designer is a graphical software which is used to build the user interface of the applications. And Thonny is used to write python code and we link the graphical user interface with Thonny and then we can execute the application which works with the designed interface.

Installation of Thonny

First of all I will install Thonny. I have followed the official link of Thonny to download it.


image.png

I am window user so I have chosen window operating system to download the software. Then from all the available versions I have selected the latest version. My window is 10 bit so I have chosen the first option which is suitable for me system.

image.png

The Thonny installer has downloaded and now I will install it in my system.


image.png

I am the only user of this system and I do not need to collaborate with anyone so I am going with the first option to install it only for me.

image.pngimage.png
Step 1Step2
image.pngimage.png
Step 3Step 4
image.pngimage.png
Step 5Step 6
image.pngimage.png
Step 7Step 8
image.pngimage.png

The installation of Thonny is completed now and we can use it now.

Installation of Qt5 Designer

I have followed the link given by the professor to download Qt Designer. But at this link I did not find Qt5 but it is a Qt designer but with the latest version.


image.png

This is the landing page followed by the link.


image.png

As I am window user so I have selected windows software for the Qt designer to download.


image.png

Qt Designer has downloaded in my system. Now I can install it. I double clicked on the setup and it asked me for the permission for the installation. I allowed it and then the system moved next.

image.pngimage.pngimage.png
Step 1Step 2Step 3


image.png

Finally the Qt Designer has installed after completing all the required steps for its installation. It is ready to use and we can start creating user interface now.

Installation of PyQt5

We can install it by going to tools and then selecting manage packages. We can find all the packages here.

image.pngimage.png
Search and select PyQt5Click on install
image.pngimage.png
Installation processInstallation completed

This is the necessary package for the use of Qt Designer with Thonny.

Installation of PyQt5-tools

The installation of PyQt5-tools is also same with the previous package.

image.pngimage.png
Search and select PyQt5-toolsClick on install
image.pngimage.png
Installation processInstallation completed

Testing and Verification

I have installed all the packages in Thonny but I do not know if it will work correctly or not. So here I am going to verify the installation process by following the guidelines given by the professor.


image.png

I have inserted the code for the verification. The code has executed successfully and we can see the output as expected. So finally I have installed the complete working environment.

Create a GUI in PyQt5 to display prime numbers between two values ​​a and b provided by the user.


image.png

According to the requirement of the task I have added the following things in the GUI.

  • Two fields for the values ​​a and b.
  • A Descending order box to sort the numbers in descending order.
  • A Display button to display the prime numbers in the interval.
  • Reset buttons to clear and Quit to close the application.

I have made a new file in Thonny. I have imported the UI in Thonny by following the commands learnt in the lesson.

The program is running without errors. The GUI made in Qt designer has also connected to Thonny. The functionality of finding prime numbers between the given range is also working fine. Moreover I have added the checkbox as per the requirement. When I am clicking the checkbox then it is changing the order of the output numbers to descending order.

Develop a GUI in PyQt5 to perform the prime factorization of a positive integer greater than 1


image.png

According to the GUI requirements I have designed the above user interface. I have added the following things:

  • I have included an input field to enter the number to decompose.
  • I have added a Decompose button to start the decomposition.
  • There is a section to display the result as a product of prime factors.
  • There is Reset button to reset the interface and Quit to close the application.

Here you can check the working and integration of the GUI with Python in Thonny. The application is running fine by synchronizing the designed GUI and python code to perform the required actions.

The input field is getting data from the user and then when the user is clicking Decompose button then the application is calculating the factorization of the number entered by the user. Similarly reset and quit buttons are also working fine.

Develop a GUI in PyQt5 to calculate the number of combinations of p elements among n (notation ( C(n, p) )), where n > p > 0.


image.png

According to the GUI requirements by the teacher I have made the above user interface. I have tried my best to align the buttons and the input fields and output at the right places according to the given design.

  • I have included two input fields for the values ​​n and p.
  • I have added a button Number of combinations to calculate and display the result of ( C(n, p) ).
  • I have added other required buttons like Reset to reset the interface and Quit to close the application.

In this video I have shown the working of the application which calculates the number of combination combinations of p elements among n (notation ( C(n, p) )), where n > p > 0. If we enter numbers without following the condition then we can face the error because the validation prints a pop up error on the screen that we should enter the numbers according to the defined condition where the number n should be greater that p and p should be greater than 0. I have shown the working with example and you can see that that the combinations have calculated successfully.

The reset button is resetting all the input and output fields. Moreover the quit button is closing the application.


I invite @ahsansharif, @starrchris, @kirvic to join this contest.

Coin Marketplace

STEEM 0.22
TRX 0.20
JST 0.035
BTC 96819.43
ETH 3313.98
USDT 1.00
SBD 3.13