This project is a simple Calculator App built using the Kivy framework for Python. It provides a graphical user interface (GUI) for performing basic mathematical calculations as well as trigonometric and logarithmic operations.
- Basic Arithmetic: Addition, subtraction, multiplication, and division.
- Advanced Operations:
- Trigonometric functions:
sin
,cos
,tan
. - Square root (
sqrt
), exponentiation (^
), and logarithm (log
).
- Trigonometric functions:
- Keyboard Support:
- Use the keyboard for numeric and operator input.
- Special keys like
Enter
for equals,Backspace
for delete, andC
for clearing the input.
- History Display: Shows the last performed calculations (limited implementation).
- Python 3.8+
- Kivy 2.1.0+
- Math module (built into Python)
-
Clone or download the repository.
-
Install the required dependencies:
pip install kivy
-
Run the application:
python calculator.py
- Launch the application to open the calculator window.
- Use the on-screen buttons or keyboard to input calculations.
- Supported buttons:
C
: Clear the current input.DEL
: Delete the last character.=
: Evaluate the current expression.sin
,cos
,tan
: Trigonometric functions.sqrt
: Square root.log
: Logarithm (base 10).^
: Exponentiation.%
: Percentage.
- Numbers and Operators: Direct input from the keyboard (e.g.,
1
,+
,-
) (For Mac OS keyboard mapping only). - Special Keys:
Enter
: Evaluate the expression.Backspace
: Delete the last character.
- Numpad Support: Handles numpad keys for numbers and operators.
-
Calculator
Class:- Handles UI creation and event processing.
- Processes input from buttons and keyboard.
- Performs mathematical operations and updates the display.
-
Key Methods:
process_input(input_text)
: Processes user input and updates the display.on_button_press(instance)
: Handles button press events.on_key_down(instance, keyboard, keycode, text, modifiers)
: Handles keyboard events.backspace()
: Deletes the last character from the input.
- Trigonometric Functions: Arguments for
sin
,cos
, andtan
must be in radians. - Logarithm: Only supports base 10.
This project is licensed under the MIT License.