mirror of
				https://github.com/python-escpos/python-escpos
				synced 2025-10-23 09:30:00 +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:
		| @@ -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 """ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Patrick Kanzler
					Patrick Kanzler