PyCalc is a sample calculator implemented using Python 3 and with a PyQt6 GUI. Fundamentally, PyCalc implements basic math operations, such as; division, multiplication, addition, and subtraction.
PyCalc is an example of how to build a Python + PyQt6 GUI application using the Model-View-Controller (MVC) pattern. It was created by following the tutorial and article at RealPython, titled "Python and PyQt: Building a GUI Desktop Calculator".
The current folder, materials-pyqt-calculator/
, hosts two subfolders:
docs/
should contain the documentation for pycalcpycalc/
stores the code and related resources for your PyQt Calculator app.
For PyCalc to work, you need to have Python >= 3.6.1. Then you need to install the PyQt6 library. You can do this by using pip
in a Python virtual environment:
$ python -m venv devenv
$ source devenv/bin/activate
$ python -m pip install pyqt6
After these commands have finished, you can run PyCalc as described in the next section.
To run PyCalc from your system's command line or terminal, execute the following command:
$ python pycalc.py
After running this command, you'll get PyCalc running on your machine. If you choose to edit the application for whatever reason, you may also wish to run it in editable mode from your virtual environment, so you can see the changes you have made right away. To do that, run the following command:
(devenv) $ pip install -e .
Run this from the project directory and it will automatically pick pycalc to install in editable mode.
To use PyCalc, just enter a valid math expression using your mouse and then press Enter
or click the =
button to get the result.
PyCalc is originally developed by Leodanis Pozo Ramos is a self-taught Python Developer, and content creator at Real Python. It is edited by Phumelela Mdluli while learning from or using RealPython to learn.
This project is distributed under the GPL license. See LICENSE
for more information.