Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/WorkTeam01/team-practice/llms.txt

Use this file to discover all available pages before exploring further.

The GUI is built with tkinter and features a dark-themed interface with an #1E1E1E background. It supports full mouse interaction via a button grid as well as complete keyboard input — every digit, operator, parenthesis, and control action has a keyboard equivalent so you never have to reach for the mouse.

Launching the GUI

Run the graphical interface from the project root:
python src/gui.py
A 330×450 window titled Calculadora opens immediately. No extra dependencies beyond a standard Python 3.12+ installation with tkinter are required.

Interface layout

The window is organised into three distinct zones stacked vertically. Display area — a wide Entry widget at the top of the window (row 0). It is right-aligned, uses 28 pt bold Arial, and shows the current number, the full expression in parenthesis mode, or the computed result. The field is also where error recovery begins: after an error the display is cleared automatically. Error label — a slim label (row 1) rendered in red (#FF4444). It is normally blank and appears only when the calculator encounters a problem, prefixed with a ⚠️ icon. Button grid — a 6-row × 4-column grid (rows 2–7) containing all 24 interactive buttons. Number buttons are dark grey (#3A3A3A); operator buttons are orange (#FF8C00); utility buttons (C, ⌫) are mid-grey (#6E6E6E).
RowCol 0Col 1Col 2Col 3
2C — clear all( — open parenthesis) — close parenthesis — backspace
3max — maximummin — minimumabs — absolute value/ — divide
4789* — multiply
5456- — subtract
6123+ — add
7^ — power0. — decimal= — evaluate

Keyboard shortcuts

Every button on the grid is reachable from the keyboard. The keypress handler maps the following keys:
KeyAction
09Enter a digit
.Decimal point
+Addition operator
-Subtraction operator (also starts a negative number when pressed first)
*Multiplication operator
/Division operator
^Power operator
(Open parenthesis (activates expression mode)
)Close parenthesis
Enter or =Evaluate / calculate result
EscapeClear — equivalent to pressing C
BackspaceDelete the last character

Performing a basic calculation

The following example calculates 15 ÷ 3 = 5 using either mouse clicks or the matching keyboard keys.
1

Enter the first number

Click 1 then 5 (or press 1 then 5). The display shows 15.
2

Choose the operator

Click / (or press /). The calculator stores 15 as the first operand and waits for the second number.
3

Enter the second number

Click 3 (or press 3). The display shows 3.
4

Evaluate

Click = (or press Enter). The display updates to 5.0.

Using parentheses

Pressing ( activates expression mode. In this mode every subsequent key press — digits, operators, more parentheses — is appended to a single expression string that is evaluated all at once when you press =. The calculator validates that parentheses are balanced before evaluating, and it converts ^ to Python’s ** internally.
In expression mode the calculator only permits digits, spaces, and the characters +-*/^(). — the regex ^[\d\s\+\-\*\/\^\(\)\.]+$ is enforced. This means abs, max, and min cannot be typed as part of a parenthesized expression; use those buttons in normal (non-parenthesis) mode instead.

Example: (2+3)*4 = 20

1

Open the parenthesis

Click ( (or press (). Expression mode activates; the display shows (.
2

Enter the sub-expression

Click 2, +, 3. The display shows (2+3.
3

Close the parenthesis

Click ) (or press )). The display shows (2+3).
4

Add the multiplier

Click *, then 4. The display shows (2+3)*4.
5

Evaluate

Click = (or press Enter). The display shows 20.

Example: ((2+3)*4)/5 = 4

1

Enter the outer opening parenthesis

Click (. Display: (.
2

Enter the inner expression

Click (, 2, +, 3, ), *, 4. Display: ((2+3)*4.
3

Close the outer parenthesis

Click ). Display: ((2+3)*4).
4

Divide by 5

Click /, then 5. Display: ((2+3)*4)/5.
5

Evaluate

Click =. The display shows 4.0.

Scientific functions

The calculator provides three scientific functions accessible from the second button row. abs — absolute value (unary) Enter a number, then click abs. The function reads current_value, calls abs_value(), and replaces the display with the result immediately — no = required.
StepActionDisplay
1Enter -5 (press - then 5)-5
2Click abs5
max — maximum of two numbers (binary) max behaves like an arithmetic operator: enter the first number, click max, enter the second number, then press =.
StepActionDisplay
1Enter 1010
2Click max10 (stored)
3Enter 2020
4Click =20
min — minimum of two numbers (binary) min works the same way as max.
StepActionDisplay
1Enter 1010
2Click min10 (stored)
3Enter 2020
4Click =10

Error handling

When an invalid operation is attempted the error label below the display lights up in red with a ⚠️ prefix and the display is cleared so you can start fresh.
Error messageTrigger condition
No se puede dividir por 0Divisor is zero in a / operation
Paréntesis desbalanceadosThe number of ( and ) in the expression do not match
Expresión inválidaThe expression contains characters outside digits and +-*/^().
Raíz negativaA negative base raised to a fractional exponent that implies an even root (e.g. (-8)^0.5)
Número inválidoA non-numeric token is encountered when one is expected
Entrada inválidaA ValueError other than Raíz negativa is raised during a normal binary calculation
Ingresa el segundo número= is pressed after an operator but before typing the second number
Número incompletoabs is clicked when current_value is exactly - (incomplete negative number)
Sintaxis incorrectaExpression mode evaluation raises a Python SyntaxError
Error messages auto-dismiss after 3 seconds. The display and all internal state are cleared immediately when the error is shown, so you can start a new calculation right away without pressing C.

Negative numbers

To enter a negative number, press - before typing any digit. When - is the very first character entered (and current_value is empty), the calculator stores it as the start of a negative number rather than treating it as a subtraction operator. For example, to enter −7:
1

Press the minus key

Click - (or press -) with an empty display. The display shows -.
2

Enter the digits

Click 7. The display shows -7.
3

Continue normally

You can now apply an operator (e.g. +) or a unary function (e.g. abs) to -7.
If you accidentally press - twice when trying to start a negative number, the second press is silently ignored — the display stays at -.

Build docs developers (and LLMs) love