From 311d0d56042266db3bcbc3af9a62722536592dd8 Mon Sep 17 00:00:00 2001 From: oleting Date: Tue, 29 Dec 2020 00:00:31 +0100 Subject: [PATCH] + new Layout --- .vscode/launch.json | 2 +- errors/custom.py | 3 +++ gui/gui.py | 25 ++++++++++++++++++------- gui/utils.py | 4 +++- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index e80f071..1ded7e8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,7 +8,7 @@ "name": "Python: Aktuelle Datei", "type": "python", "request": "launch", - "program": "debug.py", + "program": "run.py", "console": "integratedTerminal" } ] diff --git a/errors/custom.py b/errors/custom.py index 5837fb3..8d0a58a 100644 --- a/errors/custom.py +++ b/errors/custom.py @@ -6,3 +6,6 @@ class JavaSyntaxError(Exception): class ScopeNotFoundException(Exception): pass + +class NoPathError(Exception): + pass \ No newline at end of file diff --git a/gui/gui.py b/gui/gui.py index 008d2b3..be75a25 100644 --- a/gui/gui.py +++ b/gui/gui.py @@ -1,5 +1,5 @@ from gui.utils import nassi, output -from interpreter.interpret_source import JavaSyntaxError, ScopeNotFoundException, InterpreterException +from errors.custom import JavaSyntaxError, ScopeNotFoundException, InterpreterException, NoPathError from enum import IntEnum import PySimpleGUI as sg @@ -59,8 +59,12 @@ class Gui: toolbar = [ [ + sg.Button(button_text='Create Image', key='-CREATE-'), + sg.Button(button_text='Credits', key='-CREDITS-'), + # * fun feature + sg.Button(button_text='Donate', key='-DONATE-'), #sg.ButtonMenu('', menu_def), - sg.Button('TEST') + ] ] @@ -104,7 +108,7 @@ class Gui: ], [ sg.Listbox( - values=[], enable_events=True, size=(40, 20), key="-OUTPUT FILE LIST-" + values=[], enable_events=True, size=(40, 20), key="-OUTPUT FILE LIST-", ) ], ] @@ -127,10 +131,11 @@ class Gui: [ sg.Column(input_column), sg.VSeparator(), - sg.Column(execute_column), + #sg.Column(execute_column), sg.VSeparator(), sg.Column(file_list_column), sg.VSeparator(), + sg.VSeparator(), sg.Column(diagramm_viewer_column), ] ] @@ -149,7 +154,7 @@ class Gui: logging.debug('init layout GUI') - window = sg.Window('Nassi Viewer', layout_with_toolbar, resizable=True) + window = sg.Window('Nassi Viewer', layout_with_toolbar, resizable=False) return window @@ -308,8 +313,14 @@ class Gui: # output view if event == '-REFRESH-': - fnames = output(values) - window['-OUTPUT FILE LIST-'].update(fnames) + try: + fnames = output(values) + window['-OUTPUT FILE LIST-'].update(fnames) + except NoPathError: + pass + sg.popup_error('You dont set an output path. Try again.') + except: + pass window.close() if exists_choice: diff --git a/gui/utils.py b/gui/utils.py index 79a5c3f..d24f1ad 100644 --- a/gui/utils.py +++ b/gui/utils.py @@ -1,7 +1,7 @@ import os from typing import Optional - +from errors.custom import NoPathError from interpreter.NassiShneidermann import NassiShneidermanDiagram, Overwrite_behaviour, OB from draw.Iinstruction import * @@ -17,6 +17,8 @@ def nassi(input_path: str, output_path: str, outputname: str, gui, behaviour: Ov def output(values): output_path = values['-OUTPUT FOLDER-'] + if output_path == '': + raise NoPathError try: file_list = os.listdir(output_path) except: