Skip to content

Commit 7ca0b07

Browse files
committed
feat: agregar soporte para paréntesis en la calculadora y pruebas correspondientes
1 parent 75213fd commit 7ca0b07

2 files changed

Lines changed: 517 additions & 0 deletions

File tree

src/gui.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,17 @@ def open_parenthesis_click(self):
202202
>>> # Display muestra: "("
203203
>>> # use_expression_mode = True
204204
"""
205+
# Si hay algo en current_value o ya hay operación en curso, transferir a expression
206+
if not self.use_expression_mode:
207+
if self.first_number is not None:
208+
self.expression = str(self.first_number)
209+
if self.operator:
210+
self.expression += self.operator
211+
if self.current_value:
212+
self.expression += self.current_value
213+
elif self.current_value:
214+
self.expression = self.current_value
215+
205216
self.use_expression_mode = True
206217
self.expression += '('
207218
self.display.delete(0, tk.END)
@@ -408,6 +419,7 @@ def equals_click(self):
408419
self.display.insert(0, str(result))
409420

410421
# Preparar para la siguiente operación
422+
self.current_value = str(result)
411423
self.expression = str(result)
412424
self.use_expression_mode = False
413425

0 commit comments

Comments
 (0)