1
0
mirror of https://github.com/python-escpos/python-escpos synced 2025-08-24 09:03:34 +00:00

fix file-printer did not flush

The file-printer did not automatically flush and thus behaved
differently to the other printer-classes.
Now the default behaviour is to flush after every call of _raw(). This
can be disabled by calling the file-printer with auto_flush=False.

fixes #106
This commit is contained in:
Patrick Kanzler
2016-08-02 02:54:36 +02:00
parent 619d80a867
commit 3d98eb8b9c
2 changed files with 75 additions and 1 deletions

View File

@@ -229,13 +229,15 @@ class File(Escpos):
"""
def __init__(self, devfile="/dev/usb/lp0", *args, **kwargs):
def __init__(self, devfile="/dev/usb/lp0", auto_flush=True, *args, **kwargs):
"""
:param devfile : Device file under dev filesystem
:param auto_flush: automatically call flush after every call of _raw()
"""
Escpos.__init__(self, *args, **kwargs)
self.devfile = devfile
self.auto_flush = auto_flush
self.open()
def open(self):
@@ -256,6 +258,8 @@ class File(Escpos):
:type msg: bytes
"""
self.device.write(msg)
if self.auto_flush:
self.flush()
def close(self):
""" Close system file """