Add raw print (unscaled) functionality
This commit is contained in:
parent
6bcbb06c9f
commit
8e889715d1
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user