+ new structure
This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -8,7 +8,7 @@
|
|||||||
"name": "Python: Aktuelle Datei",
|
"name": "Python: Aktuelle Datei",
|
||||||
"type": "python",
|
"type": "python",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "gui.py",
|
"program": "run.py",
|
||||||
"console": "integratedTerminal"
|
"console": "integratedTerminal"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
0
__init__.py
Normal file
0
__init__.py
Normal file
@@ -1,8 +1,10 @@
|
|||||||
import code_to_image as cti
|
|
||||||
|
|
||||||
from typing import Iterable, List
|
from typing import Iterable, List
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
|
|
||||||
from code_to_image import NSD_init, NSD_save
|
from draw import code_to_image as cti
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Iinstruction:
|
class Iinstruction:
|
||||||
@@ -130,6 +132,6 @@ if __name__ == "__main__":
|
|||||||
generic_instruction("hiet()"),
|
generic_instruction("hiet()"),
|
||||||
if_instruction("shouldNiet()", [ generic_instruction("hiet()") ], [generic_instruction("hiet()")]),
|
if_instruction("shouldNiet()", [ generic_instruction("hiet()") ], [generic_instruction("hiet()")]),
|
||||||
])
|
])
|
||||||
NSD_init(500, 500)
|
cti.NSD_init(500, 500)
|
||||||
test.to_image(0, 0, 500, 500)
|
test.to_image(0, 0, 500, 500)
|
||||||
NSD_save("Iinstruction")
|
cti.NSD_save("Iinstruction")
|
||||||
0
draw/__init__.py
Normal file
0
draw/__init__.py
Normal file
124
gui.py
124
gui.py
@@ -1,124 +0,0 @@
|
|||||||
from to_nassi import nassi
|
|
||||||
import PySimpleGUI as sg
|
|
||||||
import os.path
|
|
||||||
|
|
||||||
|
|
||||||
#sg.theme_previewer()
|
|
||||||
sg.theme('DarkGrey11')
|
|
||||||
|
|
||||||
java_file_list_column = [
|
|
||||||
[
|
|
||||||
sg.Text('Java File'),
|
|
||||||
sg.In(size=(25, 1), enable_events=True, key="-JAVA FOLDER-"),
|
|
||||||
sg.FileBrowse(file_types=(('Java-File', '*.java'), ('ALL Files','*.*')), key='-JAVA FILE-'), # ('ALL Files','*.*')
|
|
||||||
],
|
|
||||||
]
|
|
||||||
|
|
||||||
file_list_column = [
|
|
||||||
[
|
|
||||||
sg.Text('Output Folder'),
|
|
||||||
sg.In(size=(25, 1), enable_events=True, key="-OUTPUT FOLDER-"),
|
|
||||||
sg.FolderBrowse(),
|
|
||||||
],
|
|
||||||
[
|
|
||||||
sg.Listbox(
|
|
||||||
values=[], enable_events=True, size=(40, 20), key="-OUTPUT FILE LIST-"
|
|
||||||
)
|
|
||||||
],
|
|
||||||
]
|
|
||||||
|
|
||||||
diagramm_viewer_column = [
|
|
||||||
[sg.Text("Choose your Code. ")],
|
|
||||||
[sg.Text(size=(40, 1), key="-TOUT-")],
|
|
||||||
[sg.Image(key='-IMAGE-')],
|
|
||||||
]
|
|
||||||
|
|
||||||
buttons_column = [
|
|
||||||
[sg.Button(button_text='Create Image', key='-CREATE-')],
|
|
||||||
[sg.Button(button_text='Donate', key='-DONATE-')],
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
layout = [
|
|
||||||
[
|
|
||||||
sg.Column(java_file_list_column),
|
|
||||||
sg.VSeparator(),
|
|
||||||
sg.Column(file_list_column),
|
|
||||||
sg.VSeparator(),
|
|
||||||
sg.Column(buttons_column),
|
|
||||||
sg.VSeparator(),
|
|
||||||
sg.Column(diagramm_viewer_column),
|
|
||||||
]
|
|
||||||
]
|
|
||||||
|
|
||||||
window = sg.Window('Nassi Viewer', layout, resizable=True)
|
|
||||||
|
|
||||||
while True:
|
|
||||||
event, values = window.read()
|
|
||||||
if event == 'Exit' or event == sg.WIN_CLOSED:
|
|
||||||
break
|
|
||||||
|
|
||||||
if event == '-OUTPUT FOLDER-':
|
|
||||||
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'))
|
|
||||||
]
|
|
||||||
window['-OUTPUT FILE LIST-'].update(fnames)
|
|
||||||
elif event == '-OUTPUT FILE LIST-':
|
|
||||||
try:
|
|
||||||
filename = os.path.join(
|
|
||||||
values["-OUTPUT FOLDER-"], values["-OUTPUT FILE LIST-"][0]
|
|
||||||
)
|
|
||||||
window["-TOUT-"].update(filename)
|
|
||||||
window["-IMAGE-"].update(filename=filename)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
if event == '-JAVA FOLDER-':
|
|
||||||
folder = values['-JAVA FOLDER-']
|
|
||||||
window['-JAVA FOLDER-'].update(values['-JAVA FILE-'])
|
|
||||||
|
|
||||||
elif event == '-CREATE-':
|
|
||||||
try:
|
|
||||||
if values['-JAVA FOLDER-'] and values['-OUTPUT FOLDER-']:
|
|
||||||
try:
|
|
||||||
file_path = os.path.join(
|
|
||||||
values["-JAVA FOLDER-"],
|
|
||||||
)
|
|
||||||
sg.popup_annoying('Succsessful created!' , title='Info')
|
|
||||||
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
output_path = values['-OUTPUT FOLDER-']
|
|
||||||
nassi(file_path, str(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'))
|
|
||||||
]
|
|
||||||
|
|
||||||
window['-OUTPUT FILE LIST-'].update(fnames)
|
|
||||||
|
|
||||||
elif values['-JAVA FOLDER-']:
|
|
||||||
print('No Output')
|
|
||||||
sg.popup_annoying('No Output' , title='Error', auto_close_duration=5, auto_close=True)
|
|
||||||
elif values['-OUTPUT FOLDER-']:
|
|
||||||
print('No Input')
|
|
||||||
sg.popup_annoying('No Input' , title='Error', auto_close_duration=5, auto_close=True)
|
|
||||||
else:
|
|
||||||
sg.popup_annoying('Unexpected Case!' , title='Error')
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
window.close()
|
|
||||||
0
gui/__init__.py
Normal file
0
gui/__init__.py
Normal file
124
gui/gui.py
Normal file
124
gui/gui.py
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
from gui.utils import nassi
|
||||||
|
import PySimpleGUI as sg
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
def gui():
|
||||||
|
#sg.theme_previewer()
|
||||||
|
sg.theme('DarkGrey11')
|
||||||
|
|
||||||
|
java_file_list_column = [
|
||||||
|
[
|
||||||
|
sg.Text('Java File'),
|
||||||
|
sg.In(size=(25, 1), enable_events=True, key="-JAVA FOLDER-"),
|
||||||
|
sg.FileBrowse(file_types=(('Java-File', '*.java'), ('ALL Files','*.*')), key='-JAVA FILE-'), # ('ALL Files','*.*')
|
||||||
|
],
|
||||||
|
]
|
||||||
|
|
||||||
|
file_list_column = [
|
||||||
|
[
|
||||||
|
sg.Text('Output Folder'),
|
||||||
|
sg.In(size=(25, 1), enable_events=True, key="-OUTPUT FOLDER-"),
|
||||||
|
sg.FolderBrowse(),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
sg.Listbox(
|
||||||
|
values=[], enable_events=True, size=(40, 20), key="-OUTPUT FILE LIST-"
|
||||||
|
)
|
||||||
|
],
|
||||||
|
]
|
||||||
|
|
||||||
|
diagramm_viewer_column = [
|
||||||
|
[sg.Text("Choose your Code. ")],
|
||||||
|
[sg.Text(size=(40, 1), key="-TOUT-")],
|
||||||
|
[sg.Image(key='-IMAGE-')],
|
||||||
|
]
|
||||||
|
|
||||||
|
buttons_column = [
|
||||||
|
[sg.Button(button_text='Create Image', key='-CREATE-')],
|
||||||
|
[sg.Button(button_text='Donate', key='-DONATE-')],
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
layout = [
|
||||||
|
[
|
||||||
|
sg.Column(java_file_list_column),
|
||||||
|
sg.VSeparator(),
|
||||||
|
sg.Column(file_list_column),
|
||||||
|
sg.VSeparator(),
|
||||||
|
sg.Column(buttons_column),
|
||||||
|
sg.VSeparator(),
|
||||||
|
sg.Column(diagramm_viewer_column),
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
window = sg.Window('Nassi Viewer', layout, resizable=True)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
event, values = window.read()
|
||||||
|
if event == 'Exit' or event == sg.WIN_CLOSED:
|
||||||
|
break
|
||||||
|
|
||||||
|
if event == '-OUTPUT FOLDER-':
|
||||||
|
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'))
|
||||||
|
]
|
||||||
|
window['-OUTPUT FILE LIST-'].update(fnames)
|
||||||
|
elif event == '-OUTPUT FILE LIST-':
|
||||||
|
try:
|
||||||
|
filename = os.path.join(
|
||||||
|
values["-OUTPUT FOLDER-"], values["-OUTPUT FILE LIST-"][0]
|
||||||
|
)
|
||||||
|
window["-TOUT-"].update(filename)
|
||||||
|
window["-IMAGE-"].update(filename=filename)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
if event == '-JAVA FOLDER-':
|
||||||
|
folder = values['-JAVA FOLDER-']
|
||||||
|
window['-JAVA FOLDER-'].update(values['-JAVA FILE-'])
|
||||||
|
|
||||||
|
elif event == '-CREATE-':
|
||||||
|
try:
|
||||||
|
if values['-JAVA FOLDER-'] and values['-OUTPUT FOLDER-']:
|
||||||
|
try:
|
||||||
|
file_path = os.path.join(
|
||||||
|
values["-JAVA FOLDER-"],
|
||||||
|
)
|
||||||
|
sg.popup_annoying('Succsessful created!' , title='Info')
|
||||||
|
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
output_path = values['-OUTPUT FOLDER-']
|
||||||
|
nassi(file_path, str(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'))
|
||||||
|
]
|
||||||
|
|
||||||
|
window['-OUTPUT FILE LIST-'].update(fnames)
|
||||||
|
|
||||||
|
elif values['-JAVA FOLDER-']:
|
||||||
|
print('No Output')
|
||||||
|
sg.popup_annoying('No Output' , title='Error', auto_close_duration=5, auto_close=True)
|
||||||
|
elif values['-OUTPUT FOLDER-']:
|
||||||
|
print('No Input')
|
||||||
|
sg.popup_annoying('No Input' , title='Error', auto_close_duration=5, auto_close=True)
|
||||||
|
else:
|
||||||
|
sg.popup_annoying('Unexpected Case!' , title='Error')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
window.close()
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
from NassiShneidermann import NassiShneidermanDiagram
|
from interpreter.NassiShneidermann import NassiShneidermanDiagram
|
||||||
from Iinstruction import *
|
from draw.Iinstruction import *
|
||||||
|
|
||||||
|
|
||||||
def nassi(filepath:str, output_path: str):
|
def nassi(filepath:str, output_path: str):
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
from Iinstruction import Iinstruction
|
|
||||||
import logging
|
import logging
|
||||||
import interpret_source as itp
|
|
||||||
import code_to_image as cti
|
from draw.Iinstruction import Iinstruction
|
||||||
|
from interpreter import interpret_source as itp
|
||||||
|
from draw import code_to_image as cti
|
||||||
|
|
||||||
|
|
||||||
class NassiShneidermanDiagram:
|
class NassiShneidermanDiagram:
|
||||||
0
interpreter/__init__.py
Normal file
0
interpreter/__init__.py
Normal file
@@ -1,8 +1,9 @@
|
|||||||
from Iinstruction import *
|
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
from typing import List, Tuple
|
from typing import List, Tuple
|
||||||
|
|
||||||
|
from draw.Iinstruction import *
|
||||||
|
|
||||||
class Scope():
|
class Scope():
|
||||||
|
|
||||||
def __init__(self, enclosing_scope) -> None:
|
def __init__(self, enclosing_scope) -> None:
|
||||||
Reference in New Issue
Block a user