Compare commits
No commits in common. "c7a2f984215eca9ab09e00b8f9b1f179e4888144" and "42062c2eb6cd825618ef91d340cd615377013ee3" have entirely different histories.
c7a2f98421
...
42062c2eb6
2 changed files with 5 additions and 30 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,7 +3,5 @@
|
|||
__pycache__/
|
||||
result*
|
||||
|
||||
.env
|
||||
|
||||
scratch.py
|
||||
test.py
|
||||
|
|
33
printer.py
33
printer.py
|
@ -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
|
||||
|
||||
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")
|
||||
from itertools import zip_longest
|
||||
|
||||
|
||||
class CallbackContext:
|
||||
|
@ -87,7 +72,7 @@ class ReceiptPrinter(CupsPrinter):
|
|||
return CallbackContext(exit=super().set_with_default)
|
||||
|
||||
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):
|
||||
return Split2Context(self, *args, **kwargs)
|
||||
|
@ -111,15 +96,7 @@ class ReceiptPrinter(CupsPrinter):
|
|||
def title(self, text, size=6, width=None, height=None):
|
||||
width = width or size
|
||||
height = height or size
|
||||
with self.set(
|
||||
align="center",
|
||||
bold=True,
|
||||
invert=True,
|
||||
smooth=True,
|
||||
custom_size=True,
|
||||
width=width,
|
||||
height=height,
|
||||
):
|
||||
with self.set(align="center", bold=True, invert=True, smooth=True, custom_size=True, width=width, height=height):
|
||||
self.textln(text)
|
||||
self.ln()
|
||||
|
||||
|
@ -127,5 +104,5 @@ class ReceiptPrinter(CupsPrinter):
|
|||
with self.set(align="center", double_height=True, double_width=True):
|
||||
p.textln(text)
|
||||
|
||||
|
||||
p = ReceiptPrinter(RECEIPT_PRINTER, profile="default")
|
||||
#p = ReceiptPrinter("EPSON-TM-m30", profile="default")
|
||||
p = ReceiptPrinter("EPSON-TM-m30-remote", profile="default")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue