Skip to content

Commit 80826f2

Browse files
committed
Last minute bug fixes
1 parent 88dd162 commit 80826f2

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

PyPortal_Calculator/calculator.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ def _handle_equal(self):
9999
self._set_text(self._accumulator)
100100
self._equal_pressed = True
101101

102+
def _update_operand(self):
103+
if self._operand is not None:
104+
self._operand = self._get_text()
105+
102106
def add_input(self, input_key):
103107
try:
104108
if self._error:
@@ -120,8 +124,10 @@ def add_input(self, input_key):
120124
self._equal_pressed = False
121125
elif input_key == "+/-":
122126
self._set_text(calculate(self._get_text(), "*", "-1"))
127+
self._update_operand()
123128
elif input_key == "%":
124129
self._set_text(calculate(self._get_text(), "/", "100"))
130+
self._update_operand()
125131
elif input_key == "=":
126132
self._handle_equal()
127133
except (ZeroDivisionError, RuntimeError):

0 commit comments

Comments
 (0)