Adjust formatting of consumable label
This commit is contained in:
parent
2dbbbd290c
commit
19fd57483d
|
@ -11,26 +11,28 @@ def print_consumable_label(item):
|
||||||
width, height = im.size
|
width, height = im.size
|
||||||
draw = ImageDraw.Draw(im)
|
draw = ImageDraw.Draw(im)
|
||||||
|
|
||||||
encodeded = urllib.parse.quote(item)
|
#logging.info('Printing consumable label item: %s', item)
|
||||||
url = 'https://spaceport.dns.t0.vc/out-of-stock?item=' + encodeded
|
|
||||||
|
|
||||||
qr = qrcode.make(url, version=6, box_size=10)
|
encodeded = urllib.parse.quote(item)
|
||||||
im.paste(qr, (800, 280))
|
url = 'https://my.protospace.ca/out-of-stock?item=' + encodeded
|
||||||
|
|
||||||
|
qr = qrcode.make(url, version=6, box_size=9)
|
||||||
|
im.paste(qr, (840, 325))
|
||||||
|
|
||||||
item_size = 150
|
item_size = 150
|
||||||
|
|
||||||
w = 9999
|
w = 9999
|
||||||
while w > 1200:
|
while w > 1200:
|
||||||
item_size -= 5
|
item_size -= 5
|
||||||
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf', item_size)
|
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', item_size)
|
||||||
w, h = draw.textsize(item, font=font)
|
w, h = draw.textsize(item, font=font)
|
||||||
|
|
||||||
x, y = (width - w) / 2, ((height - h) / 2) - 170
|
x, y = (width - w) / 2, ((height - h) / 2) - 140
|
||||||
draw.text((x, y), item, font=font, fill='black')
|
draw.text((x, y), item, font=font, fill='black')
|
||||||
|
|
||||||
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 100)
|
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 100)
|
||||||
draw.text((100, 390), 'Out of stock?', font=font, fill='black')
|
draw.text((100, 410), 'Out of stock?', font=font, fill='black')
|
||||||
draw.text((150, 540), 'Scan here:', font=font, fill='black')
|
draw.text((150, 560), 'Scan here:', font=font, fill='black')
|
||||||
|
|
||||||
im.save('tmp.png')
|
im.save('tmp.png')
|
||||||
|
|
||||||
|
|
13
main.py
13
main.py
|
@ -425,6 +425,7 @@ def print_generic_label(text):
|
||||||
im.save('tmp.png')
|
im.save('tmp.png')
|
||||||
os.system('lp -d dymo tmp.png > /dev/null 2>&1')
|
os.system('lp -d dymo tmp.png > /dev/null 2>&1')
|
||||||
|
|
||||||
|
|
||||||
def print_consumable_label(item):
|
def print_consumable_label(item):
|
||||||
im = Image.open(location + '/label.png')
|
im = Image.open(location + '/label.png')
|
||||||
width, height = im.size
|
width, height = im.size
|
||||||
|
@ -435,23 +436,23 @@ def print_consumable_label(item):
|
||||||
encodeded = urllib.parse.quote(item)
|
encodeded = urllib.parse.quote(item)
|
||||||
url = 'https://my.protospace.ca/out-of-stock?item=' + encodeded
|
url = 'https://my.protospace.ca/out-of-stock?item=' + encodeded
|
||||||
|
|
||||||
qr = qrcode.make(url, version=6, box_size=10)
|
qr = qrcode.make(url, version=6, box_size=9)
|
||||||
im.paste(qr, (800, 280))
|
im.paste(qr, (840, 325))
|
||||||
|
|
||||||
item_size = 150
|
item_size = 150
|
||||||
|
|
||||||
w = 9999
|
w = 9999
|
||||||
while w > 1200:
|
while w > 1200:
|
||||||
item_size -= 5
|
item_size -= 5
|
||||||
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf', item_size)
|
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', item_size)
|
||||||
w, h = draw.textsize(item, font=font)
|
w, h = draw.textsize(item, font=font)
|
||||||
|
|
||||||
x, y = (width - w) / 2, ((height - h) / 2) - 170
|
x, y = (width - w) / 2, ((height - h) / 2) - 140
|
||||||
draw.text((x, y), item, font=font, fill='black')
|
draw.text((x, y), item, font=font, fill='black')
|
||||||
|
|
||||||
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 100)
|
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 100)
|
||||||
draw.text((100, 390), 'Out of stock?', font=font, fill='black')
|
draw.text((100, 410), 'Out of stock?', font=font, fill='black')
|
||||||
draw.text((150, 540), 'Scan here:', font=font, fill='black')
|
draw.text((150, 560), 'Scan here:', font=font, fill='black')
|
||||||
|
|
||||||
im.save('tmp.png')
|
im.save('tmp.png')
|
||||||
os.system('lp -d dymo tmp.png > /dev/null 2>&1')
|
os.system('lp -d dymo tmp.png > /dev/null 2>&1')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user