changed logic
parent
b5584bf316
commit
d608d2f077
|
|
@ -43,10 +43,14 @@ class AbacusCore:
|
|||
:param input_str:
|
||||
:return:
|
||||
'''
|
||||
input_str = input_str.strip()
|
||||
comment = None
|
||||
orig_input_str = input_str
|
||||
if len(input_str) < 1: # leere eingabe wird nicht akzeptiert
|
||||
return
|
||||
if input_str[0] == '#': # ganze eingabe ist ein kommentar
|
||||
comment = input_str
|
||||
return None, None, None, comment
|
||||
chunks = input_str.split('#')
|
||||
if len(chunks) > 1:
|
||||
input_str = chunks[0]
|
||||
|
|
@ -56,6 +60,7 @@ class AbacusCore:
|
|||
raise ValueError('Mehrfachzuweisung wird nicht unterstützt')
|
||||
elif len(chunks) > 1:
|
||||
expression = self._with_variable_another_way(chunks[1])
|
||||
chunks[0] = '_'.join(chunks[0].strip().split(' '))
|
||||
self._vars[chunks[0]] = expression
|
||||
return
|
||||
chunks = input_str.split(':') # gibt es funktionsdefinition?
|
||||
|
|
|
|||
9
main.py
9
main.py
|
|
@ -39,7 +39,6 @@ class AbacusGUI:
|
|||
sys.exit(self._app.exec())
|
||||
|
||||
def _berechne(self):
|
||||
self._step += 1
|
||||
input_str = self._window.le_input.text()
|
||||
result = self._abacus_core.parse_input(input_str)
|
||||
if result:
|
||||
|
|
@ -48,7 +47,9 @@ class AbacusGUI:
|
|||
input_wo_var = str(result[1])
|
||||
ergebnis = str(result[2])
|
||||
comment = result[3]
|
||||
res_str = str(self._step) + '. ' + input_str + ' = ' + ergebnis
|
||||
if result[0] is not None:
|
||||
self._step += 1
|
||||
res_str = str(self._step) + '> ' + input_str + ' = ' + ergebnis
|
||||
# res_str = str(self._step) + '. ' + input_str + ' => ' + input_wo_var + ' = ' + ergebnis
|
||||
if comment:
|
||||
res_str += ' ' + comment
|
||||
|
|
@ -56,6 +57,10 @@ class AbacusGUI:
|
|||
self._history_model.appendRow(item)
|
||||
res = result[2]
|
||||
self._window.le_input.setText(str(res))
|
||||
elif result[3] is not None:
|
||||
item = QStandardItem(comment)
|
||||
self._history_model.appendRow(item)
|
||||
self._window.le_input.setText('')
|
||||
else:
|
||||
self._window.le_input.setText('')
|
||||
self._check_models()
|
||||
|
|
|
|||
Loading…
Reference in New Issue