diff --git a/batchprint.pyw b/batchprint.pyw old mode 100644 new mode 100755 index 5860571..5f42c8e --- a/batchprint.pyw +++ b/batchprint.pyw @@ -52,8 +52,13 @@ from qtpy.QtGui import * from qtpy.QtWidgets import * from qtpy.QtCore import * +# https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getdevicecaps +HORZRES = 8 +VERTRES = 10 PHYSICALWIDTH = 110 PHYSICALHEIGHT = 111 +PHYSICALOFFSETX = 112 +PHYSICALOFFSETY = 113 def getPrinters(): hive = winreg.ConnectRegistry(None,winreg.HKEY_LOCAL_MACHINE) @@ -140,18 +145,18 @@ class printerWindow(QMainWindow): except: pass self.close() - printerOpenQueue(printer) + #printerOpenQueue(printer) windows.append(queueWindow(printer)) def cOpenSettings(self): printer = self.cDropdown.currentText() + self.hide() printerOpenProperties(printer) + self.cOpenList() class queueWindow(QMainWindow): def __init__(self,printer,*args,**kwargs): super().__init__(*args,**kwargs) - self.cTitle = printer+ " - batchprint" - self.setWindowTitle(self.cTitle) self.setAcceptDrops(True) self.cWidth = 240 @@ -161,7 +166,11 @@ class queueWindow(QMainWindow): self.cPrinter = printer self.cDC = win32ui.CreateDC() self.cDC.CreatePrinterDC(printer) - self.cPrinterSize = self.cDC.GetDeviceCaps(PHYSICALWIDTH),self.cDC.GetDeviceCaps(PHYSICALHEIGHT) + self.cPrinterPhysicalSize = [self.cDC.GetDeviceCaps(PHYSICALWIDTH),self.cDC.GetDeviceCaps(PHYSICALHEIGHT)] + self.cPrinterPrintSize = [self.cDC.GetDeviceCaps(HORZRES),self.cDC.GetDeviceCaps(VERTRES)] + self.cPrinterPrintOffset = [self.cDC.GetDeviceCaps(PHYSICALOFFSETX),self.cDC.GetDeviceCaps(PHYSICALOFFSETY)] + self.cTitle = printer+ " (" +str(self.cPrinterPrintSize[0])+ "x" +str(self.cPrinterPrintSize[1])+ ") - batchprint" + self.setWindowTitle(self.cTitle) self.cCreateElements() @@ -172,7 +181,7 @@ class queueWindow(QMainWindow): self.cLabel.setWordWrap(True) self.cTick = QCheckBox(self) - self.cTick.setText("Raw print") + self.cTick.setText("Do not scale/rotate") self.cTick.setChecked(False) try: with open(p(sp,"rawprint.txt"),encoding="utf-8") as f: @@ -187,6 +196,8 @@ class queueWindow(QMainWindow): def cResizeElements(self): self.cLabel.move(0,0) self.cLabel.resize(self.cWidth,self.cHeight) + self.cTick.move(5,0) + self.cTick.resize(self.cWidth - 10,22) def resizeEvent(self,event): self.cWidth = self.width() @@ -213,13 +224,13 @@ class queueWindow(QMainWindow): if not rawprint: if bmp.size[1] > bmp.size[0]: - if self.cPrinterSize[0] > self.cPrinterSize[1]: + if self.cPrinterPrintSize[0] > self.cPrinterPrintSize[1]: bmp = bmp.transpose(PIL.Image.ROTATE_90) elif bmp.size[0] > bmp.size[1]: - if self.cPrinterSize[1] > self.cPrinterSize[0]: + if self.cPrinterPrintSize[1] > self.cPrinterPrintSize[0]: bmp = bmp.transpose(PIL.Image.ROTATE_90) - imWidth = self.cPrinterSize[0] - imHeight = self.cPrinterSize[1] + imWidth = self.cPrinterPrintSize[0] + imHeight = self.cPrinterPrintSize[1] else: imWidth = bmp.size[0] imHeight = bmp.size[1] @@ -227,7 +238,10 @@ class queueWindow(QMainWindow): self.cDC.StartDoc(path) self.cDC.StartPage() dib = PIL.ImageWin.Dib(bmp) - dib.draw(self.cDC.GetHandleOutput(),(0,0,imWidth,imHeight)) + dib.draw(self.cDC.GetHandleOutput(),( + self.cPrinterPrintOffset[0],self.cPrinterPrintOffset[1], + imWidth,imHeight + )) self.cDC.EndPage() self.cDC.EndDoc() self.cLabel.setText("Drag & Drop images here")