Merge branch 'main' of https://github.com/plexx-dev/Nassi-Shneiderman-Diagramm-Generator into main
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
__pycache__/
|
||||||
|
res/output/
|
||||||
|
res/input/
|
||||||
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Python: Aktuelle Datei",
|
||||||
|
"type": "python",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "gui.py",
|
||||||
|
"console": "integratedTerminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -131,5 +131,5 @@ if __name__ == "__main__":
|
|||||||
if_instruction("shouldNiet()", [ generic_instruction("hiet()") ], [generic_instruction("hiet()")]),
|
if_instruction("shouldNiet()", [ generic_instruction("hiet()") ], [generic_instruction("hiet()")]),
|
||||||
])
|
])
|
||||||
NSD_init(500, 500)
|
NSD_init(500, 500)
|
||||||
test.to_image(0, 0, 250, 500)
|
test.to_image(0, 0, 500, 500)
|
||||||
NSD_save("Iinstruction")
|
NSD_save("Iinstruction")
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -17,15 +17,15 @@ def NSD_init(x: float, y: float):
|
|||||||
img = Image.new("RGB", (x, y), "white")
|
img = Image.new("RGB", (x, y), "white")
|
||||||
output_img = ImageDraw.Draw(img)
|
output_img = ImageDraw.Draw(img)
|
||||||
#font = ImageFont.load_default()
|
#font = ImageFont.load_default()
|
||||||
font = ImageFont.truetype("res/fonts/NotoSans-Regular.ttf", 12)
|
font = ImageFont.truetype("res/fonts/SpaceGrotesk-Light.ttf", 12)
|
||||||
|
|
||||||
def draw_generic_instruction(instruction: str, x, y, xsize, ysize) -> Iterable[float]:
|
def draw_generic_instruction(instruction: str, x, y, xsize, ysize) -> Iterable[float]:
|
||||||
if not output_img:
|
if not output_img:
|
||||||
raise Exception("Output image was not initialized! Make sure to call NSD_init first")
|
raise Exception("Output image was not initialized! Make sure to call NSD_init first")
|
||||||
|
|
||||||
#size shit
|
#size shit
|
||||||
text_y_size = font.getsize(instruction, direction="ltr")[1]
|
#text_y_size = font.getsize(instruction, direction="ltr")[1]
|
||||||
ysize = max(text_y_size, ysize) # ensure it is alway at least big enought to fit the text
|
#ysize = max(text_y_size, ysize) # ensure it is alway at least big enought to fit the text
|
||||||
|
|
||||||
#draw shit
|
#draw shit
|
||||||
output_img.rectangle((x,y) + (x + xsize, y + ysize), outline=(0), width=1)
|
output_img.rectangle((x,y) + (x + xsize, y + ysize), outline=(0), width=1)
|
||||||
|
|||||||
12
gui.py
12
gui.py
@@ -4,6 +4,9 @@ from to_nassi import nassi
|
|||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
|
#sg.theme_previewer()
|
||||||
|
sg.theme('DarkGrey11')
|
||||||
|
|
||||||
java_file_list_column = [
|
java_file_list_column = [
|
||||||
[
|
[
|
||||||
sg.Text('Java Folder'),
|
sg.Text('Java Folder'),
|
||||||
@@ -42,13 +45,14 @@ layout = [
|
|||||||
[
|
[
|
||||||
sg.Column(java_file_list_column),
|
sg.Column(java_file_list_column),
|
||||||
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),
|
||||||
|
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
window = sg.Window('Nassi Viewer', layout)
|
window = sg.Window('Nassi Viewer', layout, resizable=True)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
event, values = window.read()
|
event, values = window.read()
|
||||||
@@ -80,7 +84,6 @@ while True:
|
|||||||
pass
|
pass
|
||||||
if event == '-JAVA FOLDER-':
|
if event == '-JAVA FOLDER-':
|
||||||
folder = values['-JAVA FOLDER-']
|
folder = values['-JAVA FOLDER-']
|
||||||
print(folder)
|
|
||||||
try:
|
try:
|
||||||
file_list = os.listdir(folder)
|
file_list = os.listdir(folder)
|
||||||
except:
|
except:
|
||||||
@@ -105,5 +108,4 @@ while True:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
window.close()
|
window.close()
|
||||||
|
|||||||
BIN
res/fonts/SpaceGrotesk-Light.ttf
Normal file
BIN
res/fonts/SpaceGrotesk-Light.ttf
Normal file
Binary file not shown.
@@ -5,4 +5,4 @@ from Iinstruction import *
|
|||||||
def nassi(filepath):
|
def nassi(filepath):
|
||||||
NSD = NassiShneidermanDiagram(True)
|
NSD = NassiShneidermanDiagram(True)
|
||||||
NSD.load_from_file(filepath)
|
NSD.load_from_file(filepath)
|
||||||
NSD.convert_to_image("Nina", 500)
|
NSD.convert_to_image("Nassi-Shneider-Diagramm", 500)
|
||||||
Reference in New Issue
Block a user