+ fix wrong output folder

This commit is contained in:
oleting
2020-12-27 19:21:16 +01:00
parent 7762ffdae4
commit 7f7c210c64
5 changed files with 20 additions and 15 deletions

View File

@@ -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(filename: str):
def NSD_save(filepath: str, filename: str):
"""Save the created file"""
img.save(filename + datei_endung ,"PNG")
img.save(filepath + '/' + filename + datei_endung ,"PNG")

View File

@@ -1,8 +1,9 @@
import draw.code_to_image as cti
class NSD_writer(object):
def __init__(self, filepath: str, x_sz: int, y_sz: int) -> None:
def __init__(self, filepath: str, filename: str, x_sz: int, y_sz: int) -> None:
self.filepath = filepath
self.filename = filename
self.x_sz = x_sz
self.y_sz = y_sz
@@ -10,4 +11,4 @@ class NSD_writer(object):
cti.NSD_init(self.x_sz, self.y_sz)
def __exit__(self, _, __, ___):
cti.NSD_save(self.filepath)
cti.NSD_save(self.filepath, self.filename)

View File

@@ -69,7 +69,7 @@ class Gui:
buttons_column = [
[sg.Button(button_text='Create Image', key='-CREATE-')],
[sg.Button(button_text='Credits', key='-CREDITS-')],
# * fun feature
[sg.Button(button_text='Donate', key='-DONATE-')],
]
@@ -95,6 +95,7 @@ class Gui:
def show_gui(self, window: sg.Window):
font_filepath = None
output_name = 'unnamed'
sg.popup('The Interpreter is WIP and cannot interpret classes or function definitions as those do not exist in Nass-Shneidermann Diagrams. A fix is in the making.',
auto_close=True, auto_close_duration=5)
@@ -104,6 +105,9 @@ class Gui:
if event == 'Exit' or event == sg.WIN_CLOSED:
logging.debug(('Exit GUI'))
break
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)))
@@ -144,14 +148,15 @@ class Gui:
values["-JAVA FOLDER-"],
)
output_path = values['-OUTPUT FOLDER-']
nassi(file_path, output_path, gui=self,
nassi(filepath=file_path, output_path=output_path, outputname=output_name, gui=self,
font_filepath=font_filepath)
fnames = output(values)
window['-OUTPUT FILE LIST-'].update(fnames)
sg.popup_annoying('Successful created!', title='Created',
auto_close_duration=2, auto_close=True, text_color='green')
window['-OUTPUT FILE LIST-'].update(fnames)
except JavaSyntaxError as JsE:
logging.error(
@@ -165,7 +170,7 @@ class Gui:
logging.error(
('||FileNotFoundError|| Failed to create Image with values = ' + str(values)))
sg.popup_error(
(str(FnFe) + 'File ' + str(file_path) + ' or ' + str(output_path) + ' is not reachable.'))
(str(FnFe) + 'File ' + str(file_path) + ' or ' + str(output_path) + ' or ' + str(font_filepath) + ' is not reachable.'))
except:
logging.error(
('Failed to create Image with values = ' + str(values)))

View File

@@ -4,17 +4,16 @@ import os
from interpreter.NassiShneidermann import NassiShneidermanDiagram
from draw.Iinstruction import *
def nassi(filepath:str, output_path: str, gui, font_filepath=None):
def nassi(filepath:str, output_path: str, outputname, gui, font_filepath=None):
NSD = NassiShneidermanDiagram(gui.debug_mode)
#if font_filepath is None:
# pass
#else:
#if font_filepath is not None or font_filepath != "":
if font_filepath != None:
print(font_filepath)
NSD.set_font(font_filepath)
NSD.set_font(str(font_filepath))
NSD.load_from_file(filepath)
NSD.convert_to_image(output_path, 500)
NSD.convert_to_image(output_path, outputname, 500)
def output(values):
output_path = values['-OUTPUT FOLDER-']

View File

@@ -29,10 +29,10 @@ class NassiShneidermanDiagram:
h += inst.getblksize()
return int(h)
def convert_to_image(self, filename: str, x_size: int=200):
def convert_to_image(self, filepath, filename: str, x_size: int=200):
image_y_sz = self._get_image_height()
logging.info(f"Saving NSD to {filename}.png...")
with NSD_writer(filename, x_size, image_y_sz):
with NSD_writer(filepath, filename, x_size, image_y_sz):
x, y = 0, 0
for instruction in self.instructions: