(printbuf, printer)
Print the buffer to a Windows printer.
Print the buffer to a Windows printer.
Print the buffer to a Windows printer .
def line_print(printbuf, printer):
    """Print the buffer to a Windows printer."""
    if not printer or printer == u'default':
        printer = get_default_printer()
    if printbuf:
        with tempfile.NamedTemporaryFile(
                suffix='.txt', prefix='pcbasic-print-', delete=False) as f:
            # write UTF-8 Byte Order mark to ensure Notepad recognises encoding
            f.write(b'\xef\xbb\xbf')
            f.write(printbuf)
        sei = SHELLEXECUTEINFO()
        sei.cbSize = ctypes.sizeof(sei)
        sei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NOASYNC
        sei.lpVerb = u'printto'
        sei.lpFile = f.name
        sei.lpParameters = u'"%s"' % printer
        sei.hProcess = HANDLE()
        try:
            _ShellExecuteEx(ctypes.byref(sei))
        except EnvironmentError as e:
            logging.error(b'Error while printing: %s', e)
        else:
            # launch non-daemon thread to wait for handle
            # to ensure we don't lose the print if triggered on exit
            threading.Thread(target=_wait_for_process, args=(sei.hProcess, f.name)).start()
def line_print ( printbuf , printer ) : if not printer or printer == u'default' : printer = get_default_printer ( ) if printbuf : with tempfile . NamedTemporaryFile ( suffix = '.txt' , prefix = 'pcbasic-print-' , delete = False ) as f : # write UTF-8 Byte Order mark to ensure Notepad recognises encoding f . write ( b'\xef\xbb\xbf' ) f . write ( printbuf ) sei = SHELLEXECUTEINFO ( ) sei . cbSize = ctypes . sizeof ( sei ) sei . fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NOASYNC sei . lpVerb = u'printto' sei . lpFile = f . name sei . lpParameters = u'"%s"' % printer sei . hProcess = HANDLE ( ) try : _ShellExecuteEx ( ctypes . byref ( sei ) ) except EnvironmentError as e : logging . error ( b'Error while printing: %s' , e ) else : # launch non-daemon thread to wait for handle # to ensure we don't lose the print if triggered on exit threading . Thread ( target = _wait_for_process , args = ( sei . hProcess , f . name ) ) . start ( )