organize code
This commit is contained in:
@@ -116,6 +116,6 @@ def draw_while_loop_back(condition: str, x: int, y: int, xsize: int, ysize: int)
|
|||||||
#the x, y offset then the x,y draw size (the canvas)
|
#the x, y offset then the x,y draw size (the canvas)
|
||||||
return x + xsize * .1, y, xsize * .9
|
return x + xsize * .1, y, xsize * .9
|
||||||
|
|
||||||
def NSD_save(filepath: str, filename: str):
|
def NSD_save(filepath: str):
|
||||||
"""Save the created file"""
|
"""Save the created file"""
|
||||||
img.save(filepath + '/' + filename + datei_endung ,"PNG")
|
img.save(filepath + datei_endung ,"PNG")
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
import draw.code_to_image as cti
|
import draw.code_to_image as cti
|
||||||
|
|
||||||
class NSD_writer(object):
|
class NSD_writer(object):
|
||||||
def __init__(self, filepath: str, filename: str, x_sz: int, y_sz: int) -> None:
|
def __init__(self, filepath: str, x_sz: int, y_sz: int) -> None:
|
||||||
self.filepath = filepath
|
self.filepath = filepath
|
||||||
self.filename = filename
|
|
||||||
self.x_sz = x_sz
|
self.x_sz = x_sz
|
||||||
self.y_sz = y_sz
|
self.y_sz = y_sz
|
||||||
|
|
||||||
@@ -11,4 +10,4 @@ class NSD_writer(object):
|
|||||||
cti.NSD_init(self.x_sz, self.y_sz)
|
cti.NSD_init(self.x_sz, self.y_sz)
|
||||||
|
|
||||||
def __exit__(self, _, __, ___):
|
def __exit__(self, _, __, ___):
|
||||||
cti.NSD_save(self.filepath, self.filename)
|
cti.NSD_save(self.filepath)
|
||||||
78
gui/gui.py
78
gui/gui.py
@@ -92,7 +92,6 @@ class Gui:
|
|||||||
sg.VSeparator(),
|
sg.VSeparator(),
|
||||||
sg.Column(file_list_column),
|
sg.Column(file_list_column),
|
||||||
sg.VSeparator(),
|
sg.VSeparator(),
|
||||||
|
|
||||||
sg.Column(diagramm_viewer_column),
|
sg.Column(diagramm_viewer_column),
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@@ -112,45 +111,12 @@ class Gui:
|
|||||||
while True:
|
while True:
|
||||||
logging.info('test')
|
logging.info('test')
|
||||||
event, values = window.read()
|
event, values = window.read()
|
||||||
|
|
||||||
if event == 'Exit' or event == sg.WIN_CLOSED:
|
if event == 'Exit' or event == sg.WIN_CLOSED:
|
||||||
logging.debug(('Exit GUI'))
|
logging.debug(('Exit GUI'))
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# execute Column
|
||||||
if event == '-SET OUTPUT NAME-':
|
|
||||||
output_name = values['-OUTPUT NAME-']
|
|
||||||
|
|
||||||
if event == '-CREDITS-':
|
|
||||||
sg.popup(
|
|
||||||
'This is made by Plexx, Weckyy and Oleting. Used PySimpleGUI and Pillow', title='Credits')
|
|
||||||
|
|
||||||
if event == '-DONATE-':
|
|
||||||
logging.debug(('event = ' + str(event)))
|
|
||||||
sg.popup_notify(
|
|
||||||
('You donated $' + str(random.randint(500, 100000000)) + '.'), title='Thanks')
|
|
||||||
|
|
||||||
if event == '-OUTPUT FOLDER-':
|
|
||||||
logging.debug(('event = ' + str(event) +
|
|
||||||
' value = ' + str(values['-OUTPUT FOLDER-'])))
|
|
||||||
fnames = output(values)
|
|
||||||
window['-OUTPUT FILE LIST-'].update(fnames)
|
|
||||||
elif event == '-OUTPUT FILE LIST-':
|
|
||||||
logging.debug(('event = ' + str(event) +
|
|
||||||
' value = ' + str(values['-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-':
|
|
||||||
logging.debug(('event = ' + str(event) +
|
|
||||||
' value = ' + str(values['-JAVA FOLDER-'])))
|
|
||||||
folder = values['-JAVA FOLDER-']
|
|
||||||
window['-JAVA FOLDER-'].update(values['-JAVA FILE-'])
|
|
||||||
|
|
||||||
if event == '-CREATE-':
|
if event == '-CREATE-':
|
||||||
logging.debug(('event = ' + str(event) +
|
logging.debug(('event = ' + str(event) +
|
||||||
'values = ' + str(values)))
|
'values = ' + str(values)))
|
||||||
@@ -168,7 +134,6 @@ class Gui:
|
|||||||
if file_there((output_path + '/' + output_name)) is True:
|
if file_there((output_path + '/' + output_name)) is True:
|
||||||
proceed = sg.popup_yes_no(
|
proceed = sg.popup_yes_no(
|
||||||
'File already exist! Continue?', title='File alreday exist!')
|
'File already exist! Continue?', title='File alreday exist!')
|
||||||
print(proceed)
|
|
||||||
if proceed == 'Yes':
|
if proceed == 'Yes':
|
||||||
nassi(filepath=file_path, output_path=output_path, outputname=output_name, gui=self,
|
nassi(filepath=file_path, output_path=output_path, outputname=output_name, gui=self,
|
||||||
font_filepath=font_filepath)
|
font_filepath=font_filepath)
|
||||||
@@ -227,6 +192,45 @@ class Gui:
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if event == '-CREDITS-':
|
||||||
|
sg.popup(
|
||||||
|
'This is made by Plexx, Weckyy and Oleting. Used PySimpleGUI and Pillow', title='Credits')
|
||||||
|
|
||||||
|
if event == '-DONATE-':
|
||||||
|
logging.debug(('event = ' + str(event)))
|
||||||
|
sg.popup_notify(
|
||||||
|
('You donated $' + str(random.randint(500, 100000000)) + '.'), title='Thanks')
|
||||||
|
|
||||||
|
# needed Input
|
||||||
|
|
||||||
|
if event == '-OUTPUT FOLDER-':
|
||||||
|
logging.debug(('event = ' + str(event) +
|
||||||
|
' value = ' + str(values['-OUTPUT FOLDER-'])))
|
||||||
|
fnames = output(values)
|
||||||
|
window['-OUTPUT FILE LIST-'].update(fnames)
|
||||||
|
elif event == '-OUTPUT FILE LIST-':
|
||||||
|
logging.debug(('event = ' + str(event) +
|
||||||
|
' value = ' + str(values['-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-':
|
||||||
|
logging.debug(('event = ' + str(event) +
|
||||||
|
' value = ' + str(values['-JAVA FOLDER-'])))
|
||||||
|
folder = values['-JAVA FOLDER-']
|
||||||
|
window['-JAVA FOLDER-'].update(values['-JAVA FILE-'])
|
||||||
|
|
||||||
|
# optional Input
|
||||||
|
|
||||||
|
if event == '-SET OUTPUT NAME-':
|
||||||
|
output_name = values['-OUTPUT NAME-']
|
||||||
|
|
||||||
if event == '-TTF FOLDER-':
|
if event == '-TTF FOLDER-':
|
||||||
logging.debug(('event = ' + str(event) +
|
logging.debug(('event = ' + str(event) +
|
||||||
' value = ' + str(values['-TTF FOLDER-'])))
|
' value = ' + str(values['-TTF FOLDER-'])))
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ def nassi(filepath: str, output_path: str, outputname: str, gui, font_filepath:
|
|||||||
if font_filepath != None:
|
if font_filepath != None:
|
||||||
NSD.set_font(font_filepath)
|
NSD.set_font(font_filepath)
|
||||||
NSD.load_from_file(filepath)
|
NSD.load_from_file(filepath)
|
||||||
NSD.convert_to_image(output_path, outputname, 500)
|
NSD.convert_to_image((output_path + outputname), 500)
|
||||||
|
|
||||||
|
|
||||||
def output(values):
|
def output(values):
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ class NassiShneidermanDiagram:
|
|||||||
h += inst.getblksize()
|
h += inst.getblksize()
|
||||||
return int(h)
|
return int(h)
|
||||||
|
|
||||||
def convert_to_image(self, filepath: str, filename: str, x_size: int=200):
|
def convert_to_image(self, filepath: str, x_size: int=200):
|
||||||
image_y_sz = self._get_image_height()
|
image_y_sz = self._get_image_height()
|
||||||
logging.info(f"Saving NSD to {filename}.png...")
|
logging.info(f"Saving NSD to {filepath}.png...")
|
||||||
with NSD_writer(filepath, filename, x_size, image_y_sz):
|
with NSD_writer(filepath, x_size, image_y_sz):
|
||||||
x, y = 0, 0
|
x, y = 0, 0
|
||||||
|
|
||||||
for instruction in self.instructions:
|
for instruction in self.instructions:
|
||||||
|
|||||||
Reference in New Issue
Block a user