mirror of
				https://github.com/python-escpos/python-escpos
				synced 2025-10-23 09:30:00 +00:00 
			
		
		
		
	Fix win32raw
This commit is contained in:
		@@ -18,6 +18,7 @@ from ..exceptions import DeviceNotFoundError
 | 
				
			|||||||
#: keeps track if the win32print dependency could be loaded (:py:class:`escpos.printer.Win32Raw`)
 | 
					#: keeps track if the win32print dependency could be loaded (:py:class:`escpos.printer.Win32Raw`)
 | 
				
			||||||
_DEP_WIN32PRINT = False
 | 
					_DEP_WIN32PRINT = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
try:
 | 
					try:
 | 
				
			||||||
    import _win32typing
 | 
					    import _win32typing
 | 
				
			||||||
    import pywintypes
 | 
					    import pywintypes
 | 
				
			||||||
@@ -65,7 +66,9 @@ class Win32Raw(Escpos):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _device: Union[Literal[False], Literal[None], _win32typing.PyPrinterHANDLE] = False
 | 
					    _device: Union[
 | 
				
			||||||
 | 
					        Literal[False], Literal[None], "_win32typing.PyPrinterHANDLE"
 | 
				
			||||||
 | 
					    ] = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @staticmethod
 | 
					    @staticmethod
 | 
				
			||||||
    def is_usable() -> bool:
 | 
					    def is_usable() -> bool:
 | 
				
			||||||
@@ -84,6 +87,7 @@ class Win32Raw(Escpos):
 | 
				
			|||||||
        self.job_name = ""
 | 
					        self.job_name = ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @property
 | 
					    @property
 | 
				
			||||||
 | 
					    @dependency_win32print
 | 
				
			||||||
    def printers(self) -> dict:
 | 
					    def printers(self) -> dict:
 | 
				
			||||||
        """Available Windows printers."""
 | 
					        """Available Windows printers."""
 | 
				
			||||||
        return {
 | 
					        return {
 | 
				
			||||||
@@ -116,7 +120,7 @@ class Win32Raw(Escpos):
 | 
				
			|||||||
            assert self.printer_name in self.printers, "Incorrect printer name"
 | 
					            assert self.printer_name in self.printers, "Incorrect printer name"
 | 
				
			||||||
            # Open device
 | 
					            # Open device
 | 
				
			||||||
            self.device: Optional[
 | 
					            self.device: Optional[
 | 
				
			||||||
                _win32typing.PyPrinterHANDLE
 | 
					                "_win32typing.PyPrinterHANDLE"
 | 
				
			||||||
            ] = win32print.OpenPrinter(self.printer_name)
 | 
					            ] = win32print.OpenPrinter(self.printer_name)
 | 
				
			||||||
            if self.device:
 | 
					            if self.device:
 | 
				
			||||||
                self.current_job = win32print.StartDocPrinter(
 | 
					                self.current_job = win32print.StartDocPrinter(
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user