+ use utils
This commit is contained in:
27
gui/gui.py
27
gui/gui.py
@@ -1,4 +1,4 @@
|
|||||||
from gui.utils import nassi
|
from gui.utils import nassi, output
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
@@ -59,17 +59,7 @@ def gui():
|
|||||||
break
|
break
|
||||||
|
|
||||||
if event == '-OUTPUT FOLDER-':
|
if event == '-OUTPUT FOLDER-':
|
||||||
output_path = values['-OUTPUT FOLDER-']
|
fnames = output(values)
|
||||||
try:
|
|
||||||
file_list = os.listdir(output_path)
|
|
||||||
except:
|
|
||||||
file_list = []
|
|
||||||
fnames = [
|
|
||||||
f
|
|
||||||
for f in file_list
|
|
||||||
if os.path.isfile(os.path.join(output_path, f))
|
|
||||||
and f.lower().endswith(('.png', '.gif'))
|
|
||||||
]
|
|
||||||
window['-OUTPUT FILE LIST-'].update(fnames)
|
window['-OUTPUT FILE LIST-'].update(fnames)
|
||||||
elif event == '-OUTPUT FILE LIST-':
|
elif event == '-OUTPUT FILE LIST-':
|
||||||
try:
|
try:
|
||||||
@@ -96,18 +86,9 @@ def gui():
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
output_path = values['-OUTPUT FOLDER-']
|
output_path = values['-OUTPUT FOLDER-']
|
||||||
nassi(file_path, str(output_path))
|
nassi(file_path, output_path)
|
||||||
try:
|
|
||||||
file_list = os.listdir(output_path)
|
|
||||||
except:
|
|
||||||
file_list = []
|
|
||||||
fnames = [
|
|
||||||
f
|
|
||||||
for f in file_list
|
|
||||||
if os.path.isfile(os.path.join(output_path, f))
|
|
||||||
and f.lower().endswith(('.png', '.gif'))
|
|
||||||
]
|
|
||||||
|
|
||||||
|
fnames = output(values)
|
||||||
window['-OUTPUT FILE LIST-'].update(fnames)
|
window['-OUTPUT FILE LIST-'].update(fnames)
|
||||||
|
|
||||||
elif values['-JAVA FOLDER-']:
|
elif values['-JAVA FOLDER-']:
|
||||||
|
|||||||
16
gui/utils.py
16
gui/utils.py
@@ -1,3 +1,5 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
from interpreter.NassiShneidermann import NassiShneidermanDiagram
|
from interpreter.NassiShneidermann import NassiShneidermanDiagram
|
||||||
from draw.Iinstruction import *
|
from draw.Iinstruction import *
|
||||||
|
|
||||||
@@ -7,6 +9,20 @@ def nassi(filepath:str, output_path: str):
|
|||||||
NSD.load_from_file(filepath)
|
NSD.load_from_file(filepath)
|
||||||
NSD.convert_to_image(output_path + "/Nassi-Shneider-Diagramm", 500)
|
NSD.convert_to_image(output_path + "/Nassi-Shneider-Diagramm", 500)
|
||||||
|
|
||||||
|
def output(values):
|
||||||
|
output_path = values['-OUTPUT FOLDER-']
|
||||||
|
try:
|
||||||
|
file_list = os.listdir(output_path)
|
||||||
|
except:
|
||||||
|
file_list = []
|
||||||
|
fnames = [
|
||||||
|
f
|
||||||
|
for f in file_list
|
||||||
|
if os.path.isfile(os.path.join(output_path, f))
|
||||||
|
and f.lower().endswith(('.png', '.gif'))
|
||||||
|
]
|
||||||
|
return fnames
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
"""Debugging"""
|
"""Debugging"""
|
||||||
nassi("res/input/input.java", "res/output")
|
nassi("res/input/input.java", "res/output")
|
||||||
Reference in New Issue
Block a user