PyQt5 How to Make GUI Calculator

In this PyQt5 article we are going to learn How to Make PyQt5 GUI Calculator,

OK before coding let’s just have a simple introduction to PyQt5.

 

 

 

Also you can check more Python GUI articles in the below links

1: Python TKinter GUI Development 

2: Psyide2 GUI Development 

3: wxPython GUI Development 

 

 

 

 

What is PyQt5 ?

PyQt5 is a binding for Qt5 C++ a GUI framework for C++ programming language, PyQt5 is used to write all kinds of GUI applications, from accounting applications, to visualization tools used by scientists and engineers.

it is possible to write PyQt5 applications that are just tens of lines long, and medium-size projects of 1000 to 10000 lines are very common. PyQt5 can be used free of charge for noncommercial purposes, Both PyQt and Qt are dual-licensed: This essentially allows them to be used to develop noncommercial  applications which must in turn be licensed using an acceptable open source license such as the GNU General Public License (GPL), or to be used to develop commercial applications in this case, a commercial PyQt license and a commercial Qt license must be purchased.

 

 

 

 

Installation

You can use pip command for the installation of PyQt5.

 

So now this is the complete code for our article, there are three different Python files,

the first one is our design, the second one is our logic file and the third one is for runing

our main PyQt5 application.

 

 

So this is the design file, the design file of this application is created by Qt Designer.

the file was ui file, but i have converted the file to Python file , and the name of  file

is ui_calculator.py.

 

 

 

 

 

This is our main logic file and i have called it calculator.py.

 

 

 

 

So this line of code is for importing our ui file.

 

 

We have created a main class that extends from the QMainWindow and also our

UI_Calculator class. you can see that we have added two variables in this class that we

will use them.

 

 

 

 

These are our QPushButton, that we are going to connect this with the specific methods or slot.

 

 

also we have connected these buttons to specific method or slot.

 

 

 

 

OK now this is our third file and i have named it main.py, in here we are going to

run our application.

 

 

 

 

So in here every PyQt5 application must create an application object. 

 

 

 

 

also we enter the mainloop of the application. The event handling starts from this point. 

 

 

 

 

If you run the code this will be the result, you need to run the code from main.py file.

PyQt5 How to Make GUI Calculator
PyQt5 How to Make GUI Calculator

 

 

Subscribe and Get Free Video Courses & Articles in your Email

 

1 thought on “PyQt5 How to Make GUI Calculator”

Comments are closed.

Share via
Copy link
Powered by Social Snap
×