Mustergenerator/A4_compositor.py

43 lines
1.2 KiB
Python
Raw Permalink Normal View History

import drawsvg as draw
import tkinter as tk
from tkinter.filedialog import askopenfilenames
import os
def get_image_path():
filepath = askopenfilenames(filetypes=[("SVG-Datei wählen", "*.svg")])
return filepath
if __name__ == '__main__':
root = tk.Tk()
root.withdraw()
filename = input("Dateiname:")
selection_flag = True
while selection_flag:
paths = get_image_path()
if len(paths) != 8:
print("Bitte wählen sie 8 *.svg-Datein aus")
else:
selection_flag = False
print(paths)
canvas = draw.Drawing(2480, 3508, origin=(0, 0))
image_1 = canvas.append(draw.Image(396, 591, 472, 472, paths[0]))
image_2 = canvas.append(draw.Image(986, 591, 472, 472, paths[1]))
image_3 = canvas.append(draw.Image(1576, 591, 472, 472, paths[2]))
image_4 = canvas.append(draw.Image(2166, 591, 472, 472, paths[3]))
image_5 = canvas.append(draw.Image(396, 1417, 472, 472, paths[4]))
image_6 = canvas.append(draw.Image(986, 1417, 472, 472, paths[5]))
image_7 = canvas.append(draw.Image(1576, 1417, 472, 472, paths[6]))
image_8 = canvas.append(draw.Image(2166, 1417, 472, 472, paths[7]))
canvas.save_svg(f'{os.getcwd()}/{filename}.svg')