The GUI is built with tkinter and features a dark-themed interface with anDocumentation 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.
#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:Interface layout
The window is organised into three distinct zones stacked vertically. Display area — a wideEntry 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).
| Row | Col 0 | Col 1 | Col 2 | Col 3 |
|---|---|---|---|---|
| 2 | C — clear all | ( — open parenthesis | ) — close parenthesis | ⌫ — backspace |
| 3 | max — maximum | min — minimum | abs — absolute value | / — divide |
| 4 | 7 | 8 | 9 | * — multiply |
| 5 | 4 | 5 | 6 | - — subtract |
| 6 | 1 | 2 | 3 | + — add |
| 7 | ^ — power | 0 | . — decimal | = — evaluate |
Keyboard shortcuts
Every button on the grid is reachable from the keyboard. The keypress handler maps the following keys:| Key | Action |
|---|---|
0 – 9 | Enter 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 |
Escape | Clear — equivalent to pressing C |
Backspace | Delete the last character |
Performing a basic calculation
The following example calculates 15 ÷ 3 = 5 using either mouse clicks or the matching keyboard keys.Choose the operator
Click
/ (or press /). The calculator stores 15 as the first operand and waits for the second number.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
Example: ((2+3)*4)/5 = 4
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.
| Step | Action | Display |
|---|---|---|
| 1 | Enter -5 (press - then 5) | -5 |
| 2 | Click abs | 5 |
max — maximum of two numbers (binary)
max behaves like an arithmetic operator: enter the first number, click max, enter the second number, then press =.
| Step | Action | Display |
|---|---|---|
| 1 | Enter 10 | 10 |
| 2 | Click max | 10 (stored) |
| 3 | Enter 20 | 20 |
| 4 | Click = | 20 |
min — minimum of two numbers (binary)
min works the same way as max.
| Step | Action | Display |
|---|---|---|
| 1 | Enter 10 | 10 |
| 2 | Click min | 10 (stored) |
| 3 | Enter 20 | 20 |
| 4 | Click = | 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 message | Trigger condition |
|---|---|
No se puede dividir por 0 | Divisor is zero in a / operation |
Paréntesis desbalanceados | The number of ( and ) in the expression do not match |
Expresión inválida | The expression contains characters outside digits and +-*/^(). |
Raíz negativa | A negative base raised to a fractional exponent that implies an even root (e.g. (-8)^0.5) |
Número inválido | A non-numeric token is encountered when one is expected |
Entrada inválida | A 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 incompleto | abs is clicked when current_value is exactly - (incomplete negative number) |
Sintaxis incorrecta | Expression 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:
