forked from emilevs/label_printer
Implement hopeful fix for cutting issues
This commit is contained in:
parent
cd4df840b6
commit
864dcb8160
1 changed files with 7 additions and 0 deletions
7
print.py
7
print.py
|
@ -3,16 +3,21 @@ from format_image import *
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import ctypes
|
import ctypes
|
||||||
import io
|
import io
|
||||||
|
import time
|
||||||
|
|
||||||
printer = ctypes.CDLL('./epson/library_bridge.so')
|
printer = ctypes.CDLL('./epson/library_bridge.so')
|
||||||
|
|
||||||
def print_text(text):
|
def print_text(text):
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
printer.print_text(b"/dev/usb/lp0", text.encode('utf-8'))
|
printer.print_text(b"/dev/usb/lp0", text.encode('utf-8'))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"An error occurred: {e}")
|
print(f"An error occurred: {e}")
|
||||||
|
|
||||||
def cut_paper():
|
def cut_paper():
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
printer.cut(b"/dev/usb/lp0")
|
printer.cut(b"/dev/usb/lp0")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -20,6 +25,8 @@ def cut_paper():
|
||||||
|
|
||||||
|
|
||||||
def print_image(image):
|
def print_image(image):
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
Bytes = io.BytesIO()
|
Bytes = io.BytesIO()
|
||||||
image.save(Bytes, format='PNG')
|
image.save(Bytes, format='PNG')
|
||||||
Bytes = Bytes.getvalue()
|
Bytes = Bytes.getvalue()
|
||||||
|
|
Loading…
Reference in a new issue