worked on gui
parent
ef5d7b9747
commit
70d02e0c1b
|
|
@ -40,10 +40,18 @@ class AbacusCore:
|
|||
:param input_str:
|
||||
:return:
|
||||
'''
|
||||
if len(input_str) < 1:
|
||||
return
|
||||
if input_str.find(':')>-1:
|
||||
chunks = input_str.split(':')
|
||||
if len(chunks) == 2:
|
||||
self._funcs[chunks[0]] = chunks[1]
|
||||
chunks = input_str.split('#')
|
||||
comment = None
|
||||
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:
|
||||
return self._with_variable(input_str)
|
||||
|
||||
|
|
@ -77,7 +85,7 @@ class AbacusCore:
|
|||
first_position = None
|
||||
new_input_str = ''
|
||||
operators = ['+', '-', '/', '*']
|
||||
delimiters = ['(', ')', '[', ']', ';']
|
||||
delimiters = ['(', ')', '[', ']', ';', ' ']
|
||||
op_del = operators + delimiters
|
||||
if input_str[0] in operators:
|
||||
input_str = 'result' + input_str
|
||||
|
|
|
|||
150
gui.ui
150
gui.ui
|
|
@ -6,22 +6,119 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>506</width>
|
||||
<height>623</height>
|
||||
<width>735</width>
|
||||
<height>770</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>AbacusNG</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<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>
|
||||
<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>
|
||||
</layout>
|
||||
</item>
|
||||
|
|
@ -46,12 +143,51 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>506</width>
|
||||
<height>33</height>
|
||||
<width>735</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</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 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>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
|
|||
28
main.py
28
main.py
|
|
@ -28,9 +28,14 @@ class AbacusGUI:
|
|||
self._window.show()
|
||||
self._window.but_enter.clicked.connect(self._berechne)
|
||||
self._window.le_input.returnPressed.connect(self._berechne)
|
||||
|
||||
self._history_model = QStandardItemModel()
|
||||
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())
|
||||
|
||||
def _berechne(self):
|
||||
|
|
@ -39,11 +44,30 @@ class AbacusGUI:
|
|||
result = self._abacus_core.parse_input(input_str)
|
||||
if 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)
|
||||
self._history_model.appendRow(item)
|
||||
res = result[2]
|
||||
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__":
|
||||
|
|
|
|||
Loading…
Reference in New Issue