[Solved] Python Label Printer Program


here is something to get you started, but I doubt it is complete. You will need to provide a valid ZPL file for making the changes.

I also made the program use fixed numbers for now and so it just runs and outputs.You can change it back once you have it working.

start = 110
end = 111

notepad = ''
# these are header lines that go once (if windows you might need \r\n instead of \n)
notepad += '^XA\n'
notepad += '^PQ2\n'
for label in range(start, end + 1):
    # use f-strings
    notepad += f'^FO185,50^A0,300^FD{label}^FS\n'
    # if you need some of those other numbers to increment
    # then setup a counter and do the math here inside the f-string
    notepad += f'^FO185,50^A0,300^FD{label}^FS\n'
notepad += '^XZ\n'
# with open('tf.txt', 'w') as sys.stdout:
#     print(notepad)
print(notepad)
exit()

outputs:

^XA
^PQ2
^FO185,50^A0,300^FD110^FS
^FO185,50^A0,300^FD110^FS
^FO185,50^A0,300^FD111^FS
^FO185,50^A0,300^FD111^FS
^XZ

solved Python Label Printer Program