示例#1
0
文件: reapair.py 项目: Foaly/ReapAir
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()
示例#2
0
import time

from escpos.printer import Usb
from PIL import Image
im = Image.open("seb.jpg")

#Epson = Usb(0x04b8,0x0202)
zj = Usb(0x0416, 0x5011)
zj.textln("See chill")
#zj.barcode("12345678", "EAN8")
impls = ["bitImageRaster", "bitImageColumns"]
#for imp in impls:
#    time.sleep(1)
#    zj.image(im, center=True, impl=imp)
long_string = """
Meine Mutter kann deine Mutter nicht kennen. Eureka (eure.ch) Protonmail lolol GPG
Meine Mutter kann deine Mutter nicht kennen. Eureka (eure.ch) Protonmail lolol GPG
Meine Mutter kann deine Mutter nicht kennen. Eureka (eure.ch) Protonmail lolol GPG
Meine Mutter kann deine Mutter nicht kennen. Eureka (eure.ch) Protonmail lolol GPG
Meine Mutter kann deine Mutter nicht kennen. Eureka (eure.ch) Protonmail lolol GPG
Meine Mutter kann deine Mutter nicht kennen. Eureka (eure.ch) Protonmail lolol GPG
Meine Mutter kann deine Mutter nicht kennen. Eureka (eure.ch) Protonmail lolol GPG

"""
#for i in range(1,5):
#    zj.textln("size = {:}".format(i))
#    zj.qr(long_string, size=i)

#zj.soft_barcode("ean8", "13375005", impl="bitImageRaster")