Compare commits

..

No commits in common. "c7a2f984215eca9ab09e00b8f9b1f179e4888144" and "42062c2eb6cd825618ef91d340cd615377013ee3" have entirely different histories.

2 changed files with 5 additions and 30 deletions

2
.gitignore vendored
View file

@ -3,7 +3,5 @@
__pycache__/ __pycache__/
result* result*
.env
scratch.py scratch.py
test.py test.py

View file

@ -1,20 +1,5 @@
import logging
import os
from itertools import zip_longest
from dotenv import find_dotenv, load_dotenv
from escpos.printer import CupsPrinter from escpos.printer import CupsPrinter
from itertools import zip_longest
log = logging.getLogger("receipt-printer")
log.setLevel(logging.WARNING)
if load_dotenv(find_dotenv(usecwd=True)):
log.debug("Loaded .env")
else:
log.debug("Didn't find .env")
RECEIPT_PRINTER = os.getenv("RECEIPT_PRINTER")
class CallbackContext: class CallbackContext:
@ -87,7 +72,7 @@ class ReceiptPrinter(CupsPrinter):
return CallbackContext(exit=super().set_with_default) return CallbackContext(exit=super().set_with_default)
def split(self, left, right, cols=48): def split(self, left, right, cols=48):
self.textln(f"{left:<{cols // 2}}{right:<{cols // 2}}") self.textln(f"{left:<{cols//2}}{right:<{cols//2}}")
def vsplit(self, *args, **kwargs): def vsplit(self, *args, **kwargs):
return Split2Context(self, *args, **kwargs) return Split2Context(self, *args, **kwargs)
@ -111,15 +96,7 @@ class ReceiptPrinter(CupsPrinter):
def title(self, text, size=6, width=None, height=None): def title(self, text, size=6, width=None, height=None):
width = width or size width = width or size
height = height or size height = height or size
with self.set( with self.set(align="center", bold=True, invert=True, smooth=True, custom_size=True, width=width, height=height):
align="center",
bold=True,
invert=True,
smooth=True,
custom_size=True,
width=width,
height=height,
):
self.textln(text) self.textln(text)
self.ln() self.ln()
@ -127,5 +104,5 @@ class ReceiptPrinter(CupsPrinter):
with self.set(align="center", double_height=True, double_width=True): with self.set(align="center", double_height=True, double_width=True):
p.textln(text) p.textln(text)
#p = ReceiptPrinter("EPSON-TM-m30", profile="default")
p = ReceiptPrinter(RECEIPT_PRINTER, profile="default") p = ReceiptPrinter("EPSON-TM-m30-remote", profile="default")