此代码用于在brother QL-800打印机上打印用于新冠病毒-19筛查的徽章
我正在使用某人在这里创建的惊人代码https://github.com/pklaus/brother_ql/tree/142cf744d89a912df729bbf15d35468d780559df/brother_ql
显然,每次我调用convert()或send()函数时,python代码都会在列表中维护我正在打印的标记
所以每次我试着打印一个新的徽章,它首先打印所有的旧徽章
在我执行convert()和send()命令打印后,有人看到如何从列表中删除徽章图像吗
代码如下:
import pygame
import time
from PIL import Image
from brother_ql.conversion import convert
from brother_ql.backends.helpers import send
from brother_ql.raster import BrotherQLRaster
from brother_ql.backends import backend_factory, guess_backend
#####################################################################################################
### Test QR-800 Printer
#####################################################################################################
# Here I just get two images each of size 1044x696
image1 = Image.open('RedBlack1_1044x696.png')
image2 = Image.open('RedBlack2_1044x696.png')
backend = 'linux_kernel' # 'pyusb', 'linux_kernel', 'network'
model = 'QL-800' # your printer model.
printer = '/dev/usb/lp0'
qlr = BrotherQLRaster(model)
qlr.exception_on_warning = True
badge = convert(
qlr=qlr,
images=[image1], # Takes a list of file names or PIL objects.
label='62red',
rotate='90', # 'Auto', '0', '90', '270'
threshold=70.0, # Black and white threshold in percent.
dither=False,
compress=False,
red=True, # Only True if using Red/Black 62 mm label tape.
dpi_600=False,
lq=False, # True for low quality.
no_cut=False
)
send(instructions=badge, printer_identifier=printer, backend_identifier=backend, blocking=True)
# THE ABOVE COMMAND PRINTS MY FIRST IMAGE (image1)
badge = convert(
qlr=qlr,
images=[image2], # Takes a list of file names or PIL objects.
label='62red',
rotate='90', # 'Auto', '0', '90', '270'
threshold=70.0, # Black and white threshold in percent.
dither=False,
compress=False,
red=True, # Only True if using Red/Black 62 mm label tape.
dpi_600=False,
lq=False, # True for low quality.
no_cut=False
)
send(instructions=badge, printer_identifier=printer, backend_identifier=backend, blocking=True)
# THE ABOVE COMMAND PRINTS BOTH IMAGES (image1 and image2). Why is it printing image1 this time????
# QUESTION - HOW DO I PREVENT IT FROM PRINTING THE FIRST IMAGE TWICE?
阅读文档here表明convert将当前图像的光栅化指令添加到发送到打印机的数据中。很可能,您需要在第二个
send()
之前重置要发送的数据一种方法是在第二个
convert()
之前使用qlr = BrotherQLRaster(model)
,但我无法测试这一点来确定,因为我没有兄弟打印机相关问题 更多 >
编程相关推荐