Create script
This commit is contained in:
parent
ee1f974588
commit
a11a3f92fb
3 changed files with 37 additions and 1 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
py/
|
||||
output_a4.svg
|
|
@ -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
26
generate_labels.py
Executable 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")
|
||||
|
Loading…
Reference in a new issue