From 8e889715d119efd8a9ff849971dcebe2ad0512b8 Mon Sep 17 00:00:00 2001 From: Fierelier Date: Wed, 23 Aug 2023 13:56:48 +0200 Subject: [PATCH] Add raw print (unscaled) functionality --- batchprint.pyw | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/batchprint.pyw b/batchprint.pyw index 064f44b..5860571 100644 --- a/batchprint.pyw +++ b/batchprint.pyw @@ -121,6 +121,8 @@ class printerWindow(QMainWindow): self.cDropdown.resize(self.cWidth - 20,22) self.cButton.move(self.cWidth - 64 - 5,self.cHeight - 22 - 5) self.cButton.resize(64,22) + self.cButtonSettings.move(5,self.cHeight - 22 - 5) + self.cButtonSettings.resize(64,22) def resizeEvent(self,event): self.cWidth = self.width() @@ -169,6 +171,16 @@ class queueWindow(QMainWindow): self.cLabel.setAlignment(Qt.AlignCenter) self.cLabel.setWordWrap(True) + self.cTick = QCheckBox(self) + self.cTick.setText("Raw print") + self.cTick.setChecked(False) + try: + with open(p(sp,"rawprint.txt"),encoding="utf-8") as f: + rawprint = int(f.read()) + if rawprint: self.cTick.setChecked(True) + except: + pass + self.cResizeElements() self.show() @@ -192,27 +204,44 @@ class queueWindow(QMainWindow): def dropEvent(self,event): self.cLabel.setStyleSheet("") + rawprint = self.cTick.isChecked() for url in event.mimeData().urls(): path = str(url.toLocalFile()).replace("/",os.path.sep) self.cLabel.setText(path.rsplit(os.path.sep,1)[-1]+ " ...") self.repaint() bmp = PIL.Image.open(path) - if bmp.size[1] > bmp.size[0]: - if self.cPrinterSize[0] > self.cPrinterSize[1]: - bmp = bmp.transpose(PIL.Image.ROTATE_90) - elif bmp.size[0] > bmp.size[1]: - if self.cPrinterSize[1] > self.cPrinterSize[0]: - bmp = bmp.transpose(PIL.Image.ROTATE_90) + + if not rawprint: + if bmp.size[1] > bmp.size[0]: + if self.cPrinterSize[0] > self.cPrinterSize[1]: + bmp = bmp.transpose(PIL.Image.ROTATE_90) + elif bmp.size[0] > bmp.size[1]: + if self.cPrinterSize[1] > self.cPrinterSize[0]: + bmp = bmp.transpose(PIL.Image.ROTATE_90) + imWidth = self.cPrinterSize[0] + imHeight = self.cPrinterSize[1] + else: + imWidth = bmp.size[0] + imHeight = bmp.size[1] self.cDC.StartDoc(path) self.cDC.StartPage() dib = PIL.ImageWin.Dib(bmp) - dib.draw(self.cDC.GetHandleOutput(),(0,0,self.cPrinterSize[0],self.cPrinterSize[1])) + dib.draw(self.cDC.GetHandleOutput(),(0,0,imWidth,imHeight)) self.cDC.EndPage() self.cDC.EndDoc() self.cLabel.setText("Drag & Drop images here") def closeEvent(self,event): + try: + with open(p(sp,"rawprint.txt"),"w",encoding="utf-8") as f: + if self.cTick.isChecked(): + f.write("1") + else: + f.write("0") + except: + pass + self.cDC.DeleteDC() windows.remove(self)