Create script

This commit is contained in:
L3D 2024-01-13 03:38:56 +01:00
parent ee1f974588
commit a11a3f92fb
No known key found for this signature in database
GPG key ID: AD65B920933B4B20
3 changed files with 37 additions and 1 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
py/
output_a4.svg

View file

@ -1,3 +1,11 @@
# homebox-label-template
Labels for homebox
## Script
```
python3 -m venv py
source py/bin/activate
cat generate_labels.py
pip install svgwrite
```

26
generate_labels.py Executable file
View file

@ -0,0 +1,26 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import svgwrite
def create_a4_svg(output_filename):
# A4 size in millimeters
a4_width = '210mm'
a4_height = '297mm'
# Create SVG document (A4)
dwg = svgwrite.Drawing(output_filename, size=(a4_width, a4_height), profile='tiny')
# Add your content or elements to the SVG here
# For example, you can add a rectangle as a placeholder
# dwg.add(dwg.rect(insert=(10, 10), size=(a4_width_svg - 20, a4_height_svg - 20), fill="white", stroke="black"))
for x in range(0,3):
for y in range(0,10):
print(f"Create Label: X={x}, Y={y}")
dwg.add(dwg.rect(insert=(f'{x*70}mm', f'{y*29.7}mm'), size=('70mm', '29.7mm'), fill="red", stroke="none"))
# Save the SVG document
dwg.save()
if __name__ == "__main__":
create_a4_svg("output_a4.svg")