簡體   English   中英

我打印圖片 X。然后我嘗試打印圖片 Y,但它再次打印圖片 X,然后是 Y。請問,如何從 Python 列表中刪除圖片 X?

[英]I print Picture X. I then try to print Picture Y but it prints Picture X again followed by Y. Please, how can I delete Picture X from a Python list?

此代碼用於在兄弟 QL-800 打印機上打印用於 COVID-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?

閱讀此處的文檔表明, convert 將當前圖像的光柵化指令添加到發送到打印機的數據中。 可能,您需要在第二次send()之前重置要發送的數據

一種方法是在第二個convert() qlr = BrotherQLRaster(model)之前使用qlr = BrotherQLRaster(model)但我無法對此進行測試以確保知道,因為我沒有 Brother 打印機。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM