https://github.com/rohancyberops/calculator
Welcome to the Calculator Project! This interactive calculator app is built using Python.
https://github.com/rohancyberops/calculator
calculator gui pygame python soundeffects tkinter
Last synced: over 1 year ago
JSON representation
Welcome to the Calculator Project! This interactive calculator app is built using Python.
- Host: GitHub
- URL: https://github.com/rohancyberops/calculator
- Owner: RohanCyberOps
- License: mit
- Created: 2025-02-05T14:24:55.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-09T13:34:13.000Z (over 1 year ago)
- Last Synced: 2025-03-10T19:51:28.071Z (over 1 year ago)
- Topics: calculator, gui, pygame, python, soundeffects, tkinter
- Language: Python
- Homepage:
- Size: 77.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
---
# ๐ **Calculator Project** ๐งฎ
## ๐ **Overview**
Welcome to the **Calculator Project**! This interactive calculator app is built using **Python**, featuring:
- **GUI** with **Tkinter**.
- **Sound effects** using **pygame**.
- **Light and Dark themes** for a better user experience.
This calculator supports essential arithmetic operations such as **Addition**, **Subtraction**, **Multiplication**, and **Division**.
 
*Above is the Calculator's GUI Interface.*
## ๐ **Features**
- โ **Basic arithmetic operations**: Add, subtract, multiply, and divide.
- ๐ฅ๏ธ **Interactive GUI** powered by **Tkinter**.
- ๐ถ **Sound effects** for each button click, powered by **pygame**.
- ๐ **Light and Dark themes** to switch between a brighter or darker interface.
## ๐ ๏ธ **Installation Guide**
### **1. Prerequisites**
Make sure you have **Python 3.x** installed on your system. Download it from the [official Python website](https://www.python.org/downloads/).
### **2. Setup the Project**
Clone the repository:
```bash
git clone https://github.com/RohanCyberOps/calculator.git
```
Navigate to the project folder:
```bash
cd calculator
```
Create a virtual environment:
```bash
python -m venv .venv
```
Activate the virtual environment:
- **For Windows**:
```bash
.venv\Scripts\activate
```
Install the required dependencies:
```bash
pip install -r requirements.txt
```
### **3. Dependencies**
- **pygame**: For sound effects.
- **tkinter**: For the graphical user interface (GUI).
## ๐ **Running the Calculator**
To run the calculator, use the following command:
```bash
python Calc.py
```
This will launch the calculator with a simple, user-friendly interface.
---
## ๐ **Sound Effects**
Make sure you have the **`click.wav`** sound file in the same directory as `Calc.py` for the button click sound to work.
---
## ๐ก **Themes**
- ๐ **Light Theme**: The default theme with bright, easy-to-read colors.
- ๐ **Dark Theme**: A more relaxed, dark-themed interface that reduces eye strain in low-light conditions.
### **Switching Themes**
To toggle between **Light** and **Dark** themes:
- A button in the UI allows you to switch themes dynamically.
- The background and button colors will change accordingly to provide a smooth transition.
---
## ๐ **Usage**
- ๐ข Click number buttons to enter digits.
- โ Use operation buttons (`+`, `-`, `*`, `/`) to perform calculations.
- ๐ฐ Click the `=` button to get the result.
- โ Click the `C` button to clear the current input.
- ๐ Toggle sound effects using the sound icon.
- ๐ Switch between **Light** and **Dark** themes using the theme toggle button.
---
## ๐ **License**
This project is licensed under the **MIT License**. Feel free to use and modify it as you like! Check the [LICENSE](LICENSE) file for more details.
---
### **Example Theme Toggle Code**
Hereโs an example of how you can implement the light and dark themes in Tkinter:
```python
import tkinter as tk
from tkinter import messagebox
# Function to switch themes
def toggle_theme():
if root.option_get('theme', 'light') == 'light':
root.tk_setPalette(background='#333333', foreground='#FFFFFF')
for widget in root.winfo_children():
widget.config(bg='#333333', fg='#FFFFFF')
root.option_add('*Button.bg', '#555555')
root.option_add('*Button.fg', '#FFFFFF')
root.option_add('*Button.activeBackground', '#666666')
root.option_add('*Button.activeForeground', '#FFFFFF')
root.option_add('*Font', 'Arial 14 bold')
root.option_add('*theme', 'dark')
else:
root.tk_setPalette(background='#FFFFFF', foreground='#000000')
for widget in root.winfo_children():
widget.config(bg='#FFFFFF', fg='#000000')
root.option_add('*Button.bg', '#DDDDDD')
root.option_add('*Button.fg', '#000000')
root.option_add('*Button.activeBackground', '#CCCCCC')
root.option_add('*Button.activeForeground', '#000000')
root.option_add('*Font', 'Arial 14 bold')
root.option_add('*theme', 'light')
# Create the main window
root = tk.Tk()
root.title("Calculator")
root.geometry("400x500")
# Create theme toggle button
toggle_button = tk.Button(root, text="Switch Theme", command=toggle_theme)
toggle_button.pack(pady=10)
# Run the application
root.mainloop()
```
This code snippet shows how you can dynamically switch between themes by updating widget colors and styles. You can expand on this by adjusting specific widgets' properties to make the theme switch smoother.
---