diff --git a/draw/code_to_image.py b/draw/code_to_image.py index 4ede92b..19d2e26 100644 --- a/draw/code_to_image.py +++ b/draw/code_to_image.py @@ -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) return x + xsize * .1, y, xsize * .9 -def NSD_save(filepath: str, filename: str): +def NSD_save(filepath: str): """Save the created file""" - img.save(filepath + '/' + filename + datei_endung ,"PNG") \ No newline at end of file + img.save(filepath + datei_endung ,"PNG") \ No newline at end of file diff --git a/draw/code_to_image_wrapper.py b/draw/code_to_image_wrapper.py index 4def001..b65896f 100644 --- a/draw/code_to_image_wrapper.py +++ b/draw/code_to_image_wrapper.py @@ -1,9 +1,8 @@ import draw.code_to_image as cti 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.filename = filename self.x_sz = x_sz self.y_sz = y_sz @@ -11,4 +10,4 @@ class NSD_writer(object): cti.NSD_init(self.x_sz, self.y_sz) def __exit__(self, _, __, ___): - cti.NSD_save(self.filepath, self.filename) \ No newline at end of file + cti.NSD_save(self.filepath) \ No newline at end of file diff --git a/gui/gui.py b/gui/gui.py index 11c0b99..167d9c1 100644 --- a/gui/gui.py +++ b/gui/gui.py @@ -92,7 +92,6 @@ class Gui: sg.VSeparator(), sg.Column(file_list_column), sg.VSeparator(), - sg.Column(diagramm_viewer_column), ] ] @@ -112,45 +111,12 @@ class Gui: while True: logging.info('test') event, values = window.read() + if event == 'Exit' or event == sg.WIN_CLOSED: logging.debug(('Exit GUI')) break - - 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-']) - + # execute Column if event == '-CREATE-': logging.debug(('event = ' + str(event) + 'values = ' + str(values))) @@ -168,7 +134,6 @@ class Gui: if file_there((output_path + '/' + output_name)) is True: proceed = sg.popup_yes_no( 'File already exist! Continue?', title='File alreday exist!') - print(proceed) if proceed == 'Yes': nassi(filepath=file_path, output_path=output_path, outputname=output_name, gui=self, font_filepath=font_filepath) @@ -227,6 +192,45 @@ class Gui: except: 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-': logging.debug(('event = ' + str(event) + ' value = ' + str(values['-TTF FOLDER-']))) diff --git a/gui/utils.py b/gui/utils.py index a2ca460..ebc5624 100644 --- a/gui/utils.py +++ b/gui/utils.py @@ -12,7 +12,7 @@ def nassi(filepath: str, output_path: str, outputname: str, gui, font_filepath: if font_filepath != None: NSD.set_font(font_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): diff --git a/interpreter/NassiShneidermann.py b/interpreter/NassiShneidermann.py index 03e3c7e..6ad95a3 100644 --- a/interpreter/NassiShneidermann.py +++ b/interpreter/NassiShneidermann.py @@ -29,10 +29,10 @@ class NassiShneidermanDiagram: h += inst.getblksize() 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() - logging.info(f"Saving NSD to {filename}.png...") - with NSD_writer(filepath, filename, x_size, image_y_sz): + logging.info(f"Saving NSD to {filepath}.png...") + with NSD_writer(filepath, x_size, image_y_sz): x, y = 0, 0 for instruction in self.instructions: