automatically open/close when cutting
This commit is contained in:
parent
4b1e49b9c5
commit
8580899a90
1 changed files with 19 additions and 0 deletions
19
printer.py
19
printer.py
|
@ -67,8 +67,19 @@ class Split2Context:
|
|||
class ReceiptPrinter(CupsPrinter):
|
||||
def __init__(self, *args, autocut=True, **kwargs):
|
||||
self.autocut = autocut
|
||||
self.is_open = False
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def open(self):
|
||||
if not self.is_open:
|
||||
super().open()
|
||||
self.is_open = True
|
||||
|
||||
def close(self):
|
||||
if self.is_open:
|
||||
super().close()
|
||||
self.is_open = False
|
||||
|
||||
def __enter__(self):
|
||||
self.open()
|
||||
return self
|
||||
|
@ -78,6 +89,14 @@ class ReceiptPrinter(CupsPrinter):
|
|||
self.cut()
|
||||
self.close()
|
||||
|
||||
def cut(self, *args, **kwargs):
|
||||
if not self.is_open:
|
||||
self.open()
|
||||
super().cut(*args, **kwargs)
|
||||
self.close()
|
||||
else:
|
||||
super().cut(*args, **kwargs)
|
||||
|
||||
def set(self, *args, **kwargs):
|
||||
super().set(*args, **kwargs)
|
||||
return CallbackContext(exit=super().set_with_default)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue