Example #1
0
def print_instructions(instructions):
    """
    Print instructions to a thermal printer.
    :param instructions: list of strings containing the instructions
    """

    try:
        # Vendor ID and Product ID of the 36-pin IEEE 1284 to USB converter,
        # this printer is so old it doesn't have USB directly
        printer = Usb(0x1a86, 0x7584, profile="TM-T88II")
    except Exception as e:
        print("Exception while trying to access printer via USB:")
        print(str(e))
        try:
            printer = File("/dev/usb/lp0", profile="TM-T88II")
        except FileNotFoundError as e:
            print(
                "Received exception while trying to access printer via File:")
            print(str(e))
            return

    # print header
    printer.set(custom_size=True, width=4, height=3)
    printer.textln(" Reparatur")
    printer.textln(" anweisung")
    printer.set()  # reset to default
    printer.ln(2)

    for instruction in instructions:
        printer.textln(instruction)
        printer.ln()
    printer.image(ASSETS_PATH / "images/combined.png", center=True)
    printer.ln()
    printer.cut()
Example #2
0
# [1] Código do movimento de portaria
# [2] Nome do motorista
# [3] OC ou SCM
# [4] Código da OC ou da SCM
# [5] Nome do usuário do protheus
# [6] tipo da refeição [1]café [2]almoço [3]janta

agora = datetime.now().strftime("%d/%m/%Y  |  %H:%M")

p = Usb(0x04B8, 0x0E27, 0, 0x81,
        0x02)  # Específico para impressora Epson TM-T20X
p.set(double_width=True, double_height=True)
p.control('HT')
p.text("    TICKET REFEICAO")
p.set(double_width=True, double_height=False)
p.ln()
p.ln()
p.text('       ' + sys.argv[1])
p.ln()
p.ln()
p.text('   ' + sys.argv[2].replace('_', ' '))
p.ln()
p.ln()
p.text('     ' + sys.argv[3] + ' ' + sys.argv[4])
p.ln()
p.ln()
if sys.argv[6] == '1':
    p.text('         ' + "Cafe")
elif sys.argv[6] == '2':
    p.text('          ' + "Almoco")
elif sys.argv[6] == '3':