Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Calculator

A desktop calculator application built with Python and Tkinter, designed to demonstrate object-oriented programming principles, GUI development, and event-driven software architecture.

The application provides a responsive user interface for performing mathematical operations while showcasing clean code organisation, modular design, and maintainable software engineering practices.


Project Overview

This project was developed to strengthen understanding of desktop application development using Python and Tkinter while applying professional software engineering concepts such as object-oriented design, event handling, and reusable component architecture.

The calculator supports common arithmetic operations, keyboard input, mathematical functions, and dynamic display management through a structured application architecture.


Engineering Highlights

Object-Oriented Architecture

Designed using object-oriented programming principles to separate application logic, user interface management, and event handling responsibilities.

Event-Driven Programming

Implemented interactive button controls and keyboard bindings that respond to user actions in real time.

GUI Development

Built a desktop user interface using Tkinter, Python's standard GUI framework, featuring dynamic displays and responsive controls.

Cross-Platform Compatibility

Designed to run on both Windows and macOS using only standard Python dependencies.


Features

Core Calculator Functions

  • Addition
  • Subtraction
  • Multiplication
  • Division

Advanced Operations

  • Square calculations (x²)
  • Square root calculations (√x)
  • Expression evaluation
  • Input clearing and reset functionality

User Experience

  • Keyboard input support
  • Interactive button interface
  • Dynamic expression display
  • Real-time calculation updates
  • Simple and intuitive layout

Technology Stack

Language

  • Python 3

GUI Framework

  • Tkinter

Programming Concepts

  • Object-Oriented Programming (OOP)
  • Event-Driven Programming
  • GUI Development
  • State Management
  • User Input Handling

Application Architecture

Python Calculator
│
├── User Interface Layer (Tkinter)
│   ├── Calculator Window
│   ├── Display Labels
│   ├── Button Components
│   └── Layout Management
│
├── Event Handling Layer
│   ├── Button Click Events
│   ├── Keyboard Input Events
│   └── Command Routing
│
├── Calculation Engine
│   ├── Arithmetic Operations
│   ├── Square Function
│   ├── Square Root Function
│   └── Expression Evaluation
│
└── Application State
    ├── Current Input
    ├── Total Expression
    └── Display Updates

Core Components

User Interface Layer

Responsible for rendering the calculator window, managing button layouts, and displaying user input and calculation results.

Event Handling Layer

Processes user interactions through button clicks and keyboard shortcuts, translating user actions into calculator operations.

Calculation Engine

Handles mathematical expression evaluation and specialised functions such as square and square root calculations.

State Management

Maintains the current expression, calculation history, and display values while ensuring the user interface remains synchronised with application data.

Technical Challenges Solved

Input Management

Implemented support for both mouse and keyboard interaction while maintaining consistent application behaviour.

Dynamic Display Updates

Created a responsive display system that updates expressions and calculation results in real time.

Event Binding

Configured keyboard shortcuts and GUI controls to provide a seamless desktop application experience.

Maintainable Code Structure

Organised application logic into reusable methods and classes to improve readability and future extensibility.


Running the Application

Clone the repository:

git clone https://github.com/harrywardy-cmd/Python-Calculator.git

cd Python-Calculator

Run the application:

python calculator.py

Requirements

Python 3.8+
Tkinter (included with standard Python installations)

No external dependencies are required.


Keyboard Shortcuts

Key Action
0-9 Enter digits
+ Addition
- Subtraction
* Multiplication
/ Division
Enter Evaluate expression
C Clear calculator

Learning Outcomes

This project provided practical experience with:

  • Object-Oriented Programming
  • Desktop Application Development
  • Event-Driven Design
  • GUI Development with Tkinter
  • User Input Validation
  • Application State Management
  • Python Software Architecture

Future Improvements

Planned Features

  • Decimal precision controls
  • Percentage calculations
  • Memory functions
  • Negative number support
  • Scientific calculator operations
  • Theme customisation
  • Improved error handling
  • Unit testing coverage

Why I Built This Project

Modern software engineering extends beyond web development and APIs.

This project was created to strengthen my understanding of desktop application development, event-driven programming, and GUI architecture while applying object-oriented design principles to a complete, user-facing application.

The calculator demonstrates how software can be structured, maintained, and extended through clean architecture and modular programming practices.


Author

Harry Ward

GitHub: https://github.com/harrywardy-cmd

Portfolio: https://harry-ward-portfolio.vercel.app

LinkedIn: https://www.linkedin.com/in/harry-ward-b2b9b4319

About

basic Python Calculator

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages