def getPrintList(self): printer = [] printerInfo = QPrinterInfo() print('availablePrinterNames', printerInfo.availablePrinterNames()) print('defaultPrinterName', printerInfo.defaultPrinterName()) for item in printerInfo.availablePrinters(): printer.append(item.printerName()) return printer
def getPrinter(p): printer = [] printerInfo = QPrinterInfo() print('availablePrinterNames', printerInfo.availablePrinterNames()) print('defaultPrinterName', printerInfo.defaultPrinterName()) for item in printerInfo.availablePrinters(): printer.append(item.printerName()) if p in printer: print(p) return p else: print(printerInfo.defaultPrinterName()) return printerInfo.defaultPrinterName()
def getPrinter(p): printer = [] printerInfo = QPrinterInfo() print('availablePrinterNames', printerInfo.availablePrinterNames()) print('defaultPrinterName', printerInfo.defaultPrinterName()) for item in printerInfo.availablePrinters(): printer.append(item.printerName()) log.write(Printer.getTime() + "--availablePrinterName --" + str(item.printerName())) if p in printer: print(p) return p else: print(printerInfo.defaultPrinterName()) log.write(Printer.getTime() + "--defaultPrinterName --" + str(printerInfo.defaultPrinterName())) return printerInfo.defaultPrinterName()
def __init__(self, p): printer = [] printerInfo = QPrinterInfo() print('availablePrinterNames', printerInfo.availablePrinterNames()) print('defaultPrinterName', printerInfo.defaultPrinterName()) if p is None or p == "": self.p = QPrinterInfo.defaultPrinter() self.print_device = QPrinter(self.p) else: for item in printerInfo.availablePrinters(): printer.append(item.printerName()) if p in printer: self.p = QPrinter(p) else: self.p = QPrinterInfo.defaultPrinter() self.print_device = QPrinter(self.p) # 指定打印所使用的装置