worked on gui
parent
ef5d7b9747
commit
70d02e0c1b
|
|
@ -40,10 +40,18 @@ class AbacusCore:
|
||||||
:param input_str:
|
:param input_str:
|
||||||
:return:
|
:return:
|
||||||
'''
|
'''
|
||||||
|
if len(input_str) < 1:
|
||||||
|
return
|
||||||
if input_str.find(':')>-1:
|
if input_str.find(':')>-1:
|
||||||
chunks = input_str.split(':')
|
chunks = input_str.split('#')
|
||||||
if len(chunks) == 2:
|
comment = None
|
||||||
self._funcs[chunks[0]] = chunks[1]
|
if len(chunks) > 1:
|
||||||
|
comment = chunks[1]
|
||||||
|
input_str = chunks[0]
|
||||||
|
inp_chunks = input_str.split(':')
|
||||||
|
if len(inp_chunks) == 2:
|
||||||
|
self._funcs[inp_chunks[0]] = inp_chunks[1]
|
||||||
|
return inp_chunks[0], inp_chunks[1], 0, comment
|
||||||
else:
|
else:
|
||||||
return self._with_variable(input_str)
|
return self._with_variable(input_str)
|
||||||
|
|
||||||
|
|
@ -77,7 +85,7 @@ class AbacusCore:
|
||||||
first_position = None
|
first_position = None
|
||||||
new_input_str = ''
|
new_input_str = ''
|
||||||
operators = ['+', '-', '/', '*']
|
operators = ['+', '-', '/', '*']
|
||||||
delimiters = ['(', ')', '[', ']', ';']
|
delimiters = ['(', ')', '[', ']', ';', ' ']
|
||||||
op_del = operators + delimiters
|
op_del = operators + delimiters
|
||||||
if input_str[0] in operators:
|
if input_str[0] in operators:
|
||||||
input_str = 'result' + input_str
|
input_str = 'result' + input_str
|
||||||
|
|
|
||||||
152
gui.ui
152
gui.ui
|
|
@ -6,22 +6,119 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>506</width>
|
<width>735</width>
|
||||||
<height>623</height>
|
<height>770</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>AbacusNG</string>
|
<string>AbacusNG</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListView" name="lv_history"/>
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Verlauf</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QListView" name="lv_history"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListView" name="lv_variable"/>
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Variablen</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QListView" name="lv_variable">
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::SelectionMode::SingleSelection</enum>
|
||||||
|
</property>
|
||||||
|
<property name="resizeMode">
|
||||||
|
<enum>QListView::ResizeMode::Adjust</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="but_var_new">
|
||||||
|
<property name="text">
|
||||||
|
<string>Neu</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="but_var_edit">
|
||||||
|
<property name="text">
|
||||||
|
<string>Bearbeiten</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="but_var_remove">
|
||||||
|
<property name="text">
|
||||||
|
<string>Löschen</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Funktionen</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QListView" name="lv_func"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="but_func_new">
|
||||||
|
<property name="text">
|
||||||
|
<string>Neu</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="but_func_edit">
|
||||||
|
<property name="text">
|
||||||
|
<string>Bearbeiten</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="but_func_remove">
|
||||||
|
<property name="text">
|
||||||
|
<string>Löschnen</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|
@ -46,12 +143,51 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>506</width>
|
<width>735</width>
|
||||||
<height>33</height>
|
<height>24</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QMenu" name="menuDatei">
|
||||||
|
<property name="title">
|
||||||
|
<string>Datei</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionNeu"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionSpeichern"/>
|
||||||
|
<addaction name="actionSpeichern_unter"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionDrucken"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionExit"/>
|
||||||
|
</widget>
|
||||||
|
<addaction name="menuDatei"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
|
<action name="actionNeu">
|
||||||
|
<property name="text">
|
||||||
|
<string>Neu</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionSpeichern">
|
||||||
|
<property name="text">
|
||||||
|
<string>Speichern</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionSpeichern_unter">
|
||||||
|
<property name="text">
|
||||||
|
<string>Speichern unter</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionDrucken">
|
||||||
|
<property name="text">
|
||||||
|
<string>Drucken</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionExit">
|
||||||
|
<property name="text">
|
||||||
|
<string>Beenden</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
|
||||||
28
main.py
28
main.py
|
|
@ -28,9 +28,14 @@ class AbacusGUI:
|
||||||
self._window.show()
|
self._window.show()
|
||||||
self._window.but_enter.clicked.connect(self._berechne)
|
self._window.but_enter.clicked.connect(self._berechne)
|
||||||
self._window.le_input.returnPressed.connect(self._berechne)
|
self._window.le_input.returnPressed.connect(self._berechne)
|
||||||
|
|
||||||
self._history_model = QStandardItemModel()
|
self._history_model = QStandardItemModel()
|
||||||
self._window.lv_history.setModel(self._history_model)
|
self._window.lv_history.setModel(self._history_model)
|
||||||
|
self._var_model = QStandardItemModel()
|
||||||
|
self._func_model = QStandardItemModel()
|
||||||
|
self._window.lv_variable.setModel(self._var_model)
|
||||||
|
self._window.lv_func.setModel(self._func_model)
|
||||||
|
# self._window.actionExit.clicked.connect(self._berechne)
|
||||||
|
self._check_models()
|
||||||
sys.exit(self._app.exec())
|
sys.exit(self._app.exec())
|
||||||
|
|
||||||
def _berechne(self):
|
def _berechne(self):
|
||||||
|
|
@ -39,11 +44,30 @@ class AbacusGUI:
|
||||||
result = self._abacus_core.parse_input(input_str)
|
result = self._abacus_core.parse_input(input_str)
|
||||||
if result:
|
if result:
|
||||||
self._history.append(result)
|
self._history.append(result)
|
||||||
res_str = str(self._step) + ': ' + result[0]+' '+str(result[3])+' : '+str(result[1])+' = '+str(result[2])
|
input_str = result[0]
|
||||||
|
input_wo_var = str(result[1])
|
||||||
|
ergebnis = str(result[2])
|
||||||
|
comment = result[3]
|
||||||
|
res_str = str(self._step) + '. ' + input_str + ' => ' + input_wo_var + ' = ' + ergebnis
|
||||||
|
if comment:
|
||||||
|
res_str += ' ' + comment
|
||||||
item = QStandardItem(res_str)
|
item = QStandardItem(res_str)
|
||||||
self._history_model.appendRow(item)
|
self._history_model.appendRow(item)
|
||||||
res = result[2]
|
res = result[2]
|
||||||
self._window.le_input.setText(str(res))
|
self._window.le_input.setText(str(res))
|
||||||
|
else:
|
||||||
|
self._window.le_input.setText('')
|
||||||
|
self._check_models()
|
||||||
|
|
||||||
|
def _check_models(self):
|
||||||
|
self._var_model.clear()
|
||||||
|
self._func_model.clear()
|
||||||
|
for k, v in self._abacus_core.get_vars().items():
|
||||||
|
item = QStandardItem(k+' = '+str(v))
|
||||||
|
self._var_model.appendRow(item)
|
||||||
|
for k, v in self._abacus_core.get_funcs().items():
|
||||||
|
item = QStandardItem(k+' = '+str(v))
|
||||||
|
self._func_model.appendRow(item)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue