This project demonstrates the creation of a basic calculator application with a graphical user interface (GUI) using Python and PyQt5. The calculator allows users to perform simple arithmetic operations such as addition, subtraction, multiplication, and division.
- Python: The core programming language used for building the application.
- PyQt5: A Python library for creating desktop applications with graphical user interfaces. PyQt5 is used to design and implement the calculator's GUI components.
The project is organized into several modules, each serving a specific purpose:
-
test.py: Initializes the PyQt5 application, creates a window, and displays a simple "hello" message to verify the window functionality.
-
view.py: Defines the GUI layout and appearance of the calculator using PyQt5 widgets, including QMainWindow, QLineEdit, QGridLayout, QPushButton, QVBoxLayout, and QWidget. It creates a display bar to show entered digits and positions buttons in the calculator layout.
-
main.py: Contains the main function that sets up the application, creates an instance of QApplication, and displays the GUI by calling the GUI() and show() methods.
-
model.py: Implements the logic for evaluating mathematical expressions entered by the user. It defines the
evaluateExpression
method to perform the calculation and handle exceptions. -
controller.py: Manages the interactions between the model and view. The Controller class connects user input from the GUI (buttons) to the expression-building logic. It includes functions for calculating results, building expressions, and connecting signals.
To run the calculator application:
-
Ensure you have Python installed on your system.
-
Install the required libraries using pip: (pip install pyqt5),(-sudo apt-get install python3- controller), model, view etc:
Basic arithmetic operations (+, -, *, /) ,Decimal support, Error handling for invalid expressions.
Add more advanced features, such as trigonometric functions and support for parentheses, Improve the user interface, Add documentation and tests.
devanshu3