load CH-Kreuz as python module, not as svg file

This commit is contained in:
Beat Jäckle 2021-12-18 22:30:16 +01:00
parent fc3a3fecf3
commit 29a7a66085
3 changed files with 23 additions and 17 deletions

View file

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 20.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg width="7mm" height="7mm" version="1.1" id="Ebene_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 19.8 19.8" style="enable-background:new 0 0 19.8 19.8;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;}
.st1{fill:none;stroke:#FFFFFF;stroke-width:1.4357;stroke-miterlimit:10;}
</style>
<polygon points="18.3,0.7 1.6,0.7 0.7,0.7 0.7,1.6 0.7,18.3 0.7,19.1 1.6,19.1 18.3,19.1 19.1,19.1 19.1,18.3 19.1,1.6 19.1,0.7 "/>
<rect x="8.3" y="4" class="st0" width="3.3" height="11"/>
<rect x="4.4" y="7.9" class="st0" width="11" height="3.3"/>
<polygon class="st1" points="0.7,1.6 0.7,18.3 0.7,19.1 1.6,19.1 18.3,19.1 19.1,19.1 19.1,18.3 19.1,1.6 19.1,0.7 18.3,0.7
1.6,0.7 0.7,0.7 "/>
</svg>

Before

Width:  |  Height:  |  Size: 903 B

20
ch_kreuz.py Normal file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env python3
import svgutils.transform as st
def swisscross():
return st.fromstring(
'<?xml version="1.0" encoding="utf-8"?>\
<svg width="7mm" height="7mm" version="1.1" id="Ebene_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\
viewBox="0 0 19.8 19.8" style="enable-background:new 0 0 19.8 19.8;" xml:space="preserve">\
<style type="text/css">\
.st0{fill:#FFFFFF;}\
.st1{fill:none;stroke:#FFFFFF;stroke-width:1.4357;stroke-miterlimit:10;}\
</style>\
<polygon points="18.3,0.7 1.6,0.7 0.7,0.7 0.7,1.6 0.7,18.3 0.7,19.1 1.6,19.1 18.3,19.1 19.1,19.1 19.1,18.3 19.1,1.6 19.1,0.7 "/>\
<rect x="8.3" y="4" class="st0" width="3.3" height="11"/>\
<rect x="4.4" y="7.9" class="st0" width="11" height="3.3"/>\
<polygon class="st1" points="0.7,1.6 0.7,18.3 0.7,19.1 1.6,19.1 18.3,19.1 19.1,19.1 19.1,18.3 19.1,1.6 19.1,0.7 18.3,0.7 1.6,0.7 0.7,0.7 "/>\
</svg>'
).getroot()

6
qrr.py
View file

@ -3,8 +3,8 @@
import os.path
import qrcode
import qrcode.image.svg
import svgutils.transform as st
from svgutils import transform as st
from ch_kreuz import swisscross as get_swisscross
class qr_rechnung():
data = ''
@ -39,7 +39,7 @@ class qr_rechnung():
qrcode = st.fromfile(filepath)
offset = self.calc_move_offset(qrcode.get_size()[0])
swisscross = st.fromfile("CH-Kreuz_7mm.svg").getroot()
swisscross = get_swisscross()
swisscross.moveto(
x=offset['offset'],
y=offset['offset'],