A simple GUI calculator built using Python and Tkinter.
This project is a basic calculator implemented with Python's Tkinter module. It supports basic arithmetic operations like addition, subtraction, multiplication, and division. The calculator also features a clear button to reset the input and basic error handling for invalid operations (e.g., division by zero).
.
├── main.py
└── Components
├── Calculator_Entry.py
└── Calculator_Button.py
- main.py: The main entry point that sets up the main window and integrates all components.
- Components/Calculator_Entry.py: Contains the definition of the Entry widget for user input and result display.
- Components/Calculator_Button.py: Contains the
CalculatorButtons
class that creates the calculator buttons and defines their functionality.
- GUI-based Calculator: Built using Tkinter for a graphical user interface.
- Basic Arithmetic Operations: Supports addition (
+
), subtraction (-
), multiplication (*
), and division (/
). - Clear Functionality: A "CL" button to clear the current input.
- Error Handling: Displays "Error" when encountering division by zero or invalid input.
- Responsive Layout: Utilizes Tkinter's grid layout for a clean, organized interface.
- Python 3.x installed on your system.
- Git (to clone the repository).
-
Clone the repository:
git clone https://github.com/ParisaAlizadeh2003/calculator.git cd calculator
-
(Optional) Create and activate a virtual environment:
python -m venv venv # On Windows: venv\Scripts\activate # On Unix or MacOS: source venv/bin/activate
-
Run the application:
python main.py
- Launch the Calculator: Run
main.py
to start the application. - Input Numbers and Operations: Use the on-screen buttons to enter numbers and arithmetic operators.
- Compute the Result: Press the
=
button to evaluate the expression and display the result. - Clear Input: Press the
CL
button to clear the current input. - Error Handling: If an error occurs (e.g., division by zero), the calculator displays "Error".
- Enhanced UI/UX: Improve the design and layout with more advanced styling.
- Keyboard Support: Allow users to input numbers and operations via the keyboard.
- Additional Features: Support for advanced mathematical functions like square roots, percentages, etc.
- Calculation History: Implement a feature to display past calculations.
Contributions are welcome! If you have suggestions or improvements, please open an issue or submit a pull request.
This project is open-sourced under the MIT License.