Fix syntax
This commit is contained in:
parent
d5b9d99093
commit
73fff6291d
|
@ -336,16 +336,16 @@ class Dummy(Escpos):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
_WIN32PRINT=False
|
_WIN32PRINT = False
|
||||||
try:
|
try:
|
||||||
import win32print
|
import win32print
|
||||||
_WIN32PRINT=True
|
_WIN32PRINT = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if _WIN32PRINT:
|
if _WIN32PRINT:
|
||||||
class Win32Raw(Escpos):
|
class Win32Raw(Escpos):
|
||||||
def __init__(self, printer_name = None, profile=None, magic_encode_args=None, **kwargs):
|
def __init__(self, printer_name=None, profile=None, magic_encode_args=None, **kwargs):
|
||||||
super().__init__(profile=profile, magic_encode_args=magic_encode_args, **kwargs)
|
super().__init__(profile=profile, magic_encode_args=magic_encode_args, **kwargs)
|
||||||
if printer_name is not None:
|
if printer_name is not None:
|
||||||
self.printer_name = printer_name
|
self.printer_name = printer_name
|
||||||
|
@ -353,20 +353,19 @@ if _WIN32PRINT:
|
||||||
self.printer_name = win32print.GetDefaultPrinter()
|
self.printer_name = win32print.GetDefaultPrinter()
|
||||||
self.hPrinter = None
|
self.hPrinter = None
|
||||||
|
|
||||||
|
|
||||||
def open(self, job_name="python-escpos"):
|
def open(self, job_name="python-escpos"):
|
||||||
if self.printer_name is None:
|
if self.printer_name is None:
|
||||||
raise Exception("Printer not found")
|
raise Exception("Printer not found")
|
||||||
self.hPrinter = win32print.OpenPrinter (self.printer_name)
|
self.hPrinter = win32print.OpenPrinter(self.printer_name)
|
||||||
self.current_job = win32print.StartDocPrinter (self.hPrinter, 1, (job_name, None, "RAW"))
|
self.current_job = win32print.StartDocPrinter(self.hPrinter, 1, (job_name, None, "RAW"))
|
||||||
win32print.StartPagePrinter (self.hPrinter)
|
win32print.StartPagePrinter(self.hPrinter)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if not self.hPrinter:
|
if not self.hPrinter:
|
||||||
return
|
return
|
||||||
win32print.EndPagePrinter (self.hPrinter)
|
win32print.EndPagePrinter(self.hPrinter)
|
||||||
win32print.EndDocPrinter (self.hPrinter)
|
win32print.EndDocPrinter(self.hPrinter)
|
||||||
win32print.ClosePrinter (self.hPrinter)
|
win32print.ClosePrinter(self.hPrinter)
|
||||||
self.hPrinter = None
|
self.hPrinter = None
|
||||||
|
|
||||||
def _raw(self, msg):
|
def _raw(self, msg):
|
||||||
|
@ -379,6 +378,4 @@ if _WIN32PRINT:
|
||||||
raise Exception("Printer not found")
|
raise Exception("Printer not found")
|
||||||
if self.hPrinter is None:
|
if self.hPrinter is None:
|
||||||
raise Exception("Printer job not opened")
|
raise Exception("Printer job not opened")
|
||||||
win32print.WritePrinter (self.hPrinter, msg)
|
win32print.WritePrinter(self.hPrinter, msg)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue