-
-
Save matteomattei/4a80294307e5d8075891 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?> | |
<DieCutLabel Version="8.0" Units="twips"> | |
<PaperOrientation>Portrait</PaperOrientation> | |
<Id>Small30332</Id> | |
<PaperName>30332 1 in x 1 in</PaperName> | |
<DrawCommands> | |
<RoundRectangle X="0" Y="0" Width="1440" Height="1440" Rx="180" Ry="180" /> | |
</DrawCommands> | |
<ObjectInfo> | |
<TextObject> | |
<Name>TEXT1</Name> | |
<ForeColor Alpha="255" Red="0" Green="0" Blue="0" /> | |
<BackColor Alpha="0" Red="255" Green="255" Blue="255" /> | |
<LinkedObjectName></LinkedObjectName> | |
<Rotation>Rotation0</Rotation> | |
<IsMirrored>False</IsMirrored> | |
<IsVariable>True</IsVariable> | |
<HorizontalAlignment>Center</HorizontalAlignment> | |
<VerticalAlignment>Top</VerticalAlignment> | |
<TextFitMode>ShrinkToFit</TextFitMode> | |
<UseFullFontHeight>True</UseFullFontHeight> | |
<Verticalized>False</Verticalized> | |
<StyledText> | |
<Element> | |
<String>Today</String> | |
<Attributes> | |
<Font Family="Arial" Size="16" Bold="False" Italic="False" Underline="False" Strikeout="False" /> | |
<ForeColor Alpha="255" Red="0" Green="0" Blue="0" /> | |
</Attributes> | |
</Element> | |
</StyledText> | |
</TextObject> | |
<Bounds X="82" Y="150" Width="1301" Height="195" /> | |
</ObjectInfo> | |
<ObjectInfo> | |
<TextObject> | |
<Name>TEXT2</Name> | |
<ForeColor Alpha="255" Red="0" Green="0" Blue="0" /> | |
<BackColor Alpha="0" Red="255" Green="255" Blue="255" /> | |
<LinkedObjectName></LinkedObjectName> | |
<Rotation>Rotation0</Rotation> | |
<IsMirrored>False</IsMirrored> | |
<IsVariable>True</IsVariable> | |
<HorizontalAlignment>Center</HorizontalAlignment> | |
<VerticalAlignment>Top</VerticalAlignment> | |
<TextFitMode>ShrinkToFit</TextFitMode> | |
<UseFullFontHeight>True</UseFullFontHeight> | |
<Verticalized>False</Verticalized> | |
<StyledText> | |
<Element> | |
<String>START_DATE</String> | |
<Attributes> | |
<Font Family="Arial" Size="18" Bold="False" Italic="False" Underline="False" Strikeout="False" /> | |
<ForeColor Alpha="255" Red="0" Green="0" Blue="0" /> | |
</Attributes> | |
</Element> | |
</StyledText> | |
</TextObject> | |
<Bounds X="82" Y="375" Width="1301" Height="360" /> | |
</ObjectInfo> | |
<ObjectInfo> | |
<TextObject> | |
<Name>TEXT3</Name> | |
<ForeColor Alpha="255" Red="0" Green="0" Blue="0" /> | |
<BackColor Alpha="0" Red="255" Green="255" Blue="255" /> | |
<LinkedObjectName></LinkedObjectName> | |
<Rotation>Rotation0</Rotation> | |
<IsMirrored>False</IsMirrored> | |
<IsVariable>False</IsVariable> | |
<HorizontalAlignment>Left</HorizontalAlignment> | |
<VerticalAlignment>Top</VerticalAlignment> | |
<TextFitMode>ShrinkToFit</TextFitMode> | |
<UseFullFontHeight>True</UseFullFontHeight> | |
<Verticalized>False</Verticalized> | |
<StyledText> | |
<Element> | |
<String>Next month</String> | |
<Attributes> | |
<Font Family="Arial" Size="16" Bold="False" Italic="False" Underline="False" Strikeout="False" /> | |
<ForeColor Alpha="255" Red="0" Green="0" Blue="0" /> | |
</Attributes> | |
</Element> | |
</StyledText> | |
</TextObject> | |
<Bounds X="82" Y="757.5" Width="1301" Height="172.5" /> | |
</ObjectInfo> | |
<ObjectInfo> | |
<TextObject> | |
<Name>TEXT4</Name> | |
<ForeColor Alpha="255" Red="0" Green="0" Blue="0" /> | |
<BackColor Alpha="0" Red="255" Green="255" Blue="255" /> | |
<LinkedObjectName></LinkedObjectName> | |
<Rotation>Rotation0</Rotation> | |
<IsMirrored>False</IsMirrored> | |
<IsVariable>False</IsVariable> | |
<HorizontalAlignment>Left</HorizontalAlignment> | |
<VerticalAlignment>Top</VerticalAlignment> | |
<TextFitMode>ShrinkToFit</TextFitMode> | |
<UseFullFontHeight>True</UseFullFontHeight> | |
<Verticalized>False</Verticalized> | |
<StyledText> | |
<Element> | |
<String>END_DATE</String> | |
<Attributes> | |
<Font Family="Arial" Size="18" Bold="False" Italic="False" Underline="False" Strikeout="False" /> | |
<ForeColor Alpha="255" Red="0" Green="0" Blue="0" /> | |
</Attributes> | |
</Element> | |
</StyledText> | |
</TextObject> | |
<Bounds X="82" Y="1009" Width="1301" Height="345" /> | |
</ObjectInfo> | |
</DieCutLabel> |
#!/usr/bin/env python | |
import sys | |
from os import path | |
from datetime import datetime, timedelta | |
from win32com.client import Dispatch | |
from tkinter import Tk | |
import tkinter.messagebox as mbox | |
curdir = None | |
if getattr(sys, 'frozen', False): | |
# frozen | |
curdir = path.dirname(sys.executable) | |
else: | |
# unfrozen | |
curdir = path.dirname(path.abspath(__file__)) | |
mylabel = path.join(curdir,'my.label') | |
window = Tk() | |
window.wm_withdraw() | |
if not path.isfile(mylabel): | |
mbox.showinfo('PyDymoLabel','Template file my.label does not exist') | |
sys.exit(1) | |
try: | |
now = datetime.now() | |
next = now + timedelta(30) | |
labelCom = Dispatch('Dymo.DymoAddIn') | |
labelText = Dispatch('Dymo.DymoLabels') | |
isOpen = labelCom.Open(mylabel) | |
selectPrinter = 'DYMO LabelWriter 450' | |
labelCom.SelectPrinter(selectPrinter) | |
labelText.SetField('TEXT1', now.strftime('%Y/%m/%d')) | |
labelText.SetField('TEXT2', next.strftime('%Y/%m/%d')) | |
labelCom.StartPrintJob() | |
labelCom.Print(1,False) | |
labelCom.EndPrintJob() | |
except: | |
mbox.showinfo('PyDymoLabel','An error occurred during printing.') | |
sys.exit(1) | |
mbox.showinfo('PyDymoLabel','Label printed!') | |
sys.exit(0) |
I am sorry but I cannot help you... I don't have windows to reproduce the issue :-(
Hi, thank you for sharing the code! It seems python can't find the proper SDK and I keep getting the bad dispatch error. Installing the SDK v.8 seems to only install samples. I've installed the connect software and it works just fine. Do I need to add some folder to the user env variables on windows?
Did you happen to figure anything out @chuckedfromspace ? Experiencing the same issue..
Hi, thank you for sharing the code! It seems python can't find the proper SDK and I keep getting the bad dispatch error. Installing the SDK v.8 seems to only install samples. I've installed the connect software and it works just fine. Do I need to add some folder to the user env variables on windows?
Did you happen to figure anything out @chuckedfromspace ? Experiencing the same issue..
Unfortunately no. I gave up and switched to using DYMO's Javascript framework.
Hi, thank you for sharing the code! It seems python can't find the proper SDK and I keep getting the bad dispatch error. Installing the SDK v.8 seems to only install samples. I've installed the connect software and it works just fine. Do I need to add some folder to the user env variables on windows?