From 67f30b55bb7b467835f43f413710b1ea0c63be6f Mon Sep 17 00:00:00 2001 From: Fierelier Date: Wed, 23 Aug 2023 13:55:19 +0200 Subject: [PATCH] Save last printer --- batchprint.pyw | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/batchprint.pyw b/batchprint.pyw index 39fc2b4..0862235 100644 --- a/batchprint.pyw +++ b/batchprint.pyw @@ -95,7 +95,14 @@ class printerWindow(QMainWindow): self.cLabel.setText("Choose a printer:") self.cLabel.setAlignment(Qt.AlignCenter) self.cDropdown = QComboBox(self) - self.cDropdown.addItems(printers) + self.cDropdown.addItems(self.cPrinters) + try: + with open(p(sp,"lastprinter.txt"),"r",encoding="utf-8") as f: + printer = f.read() + self.cDropdown.setCurrentIndex(self.cPrinters.index(printer)) + except: + pass + self.cButton = QPushButton(self) self.cButton.setText("OK") self.cButton.clicked.connect(self.cOpenList) @@ -121,6 +128,11 @@ class printerWindow(QMainWindow): def cOpenList(self): printer = self.cDropdown.currentText() + try: + with open(p(sp,"lastprinter.txt"),"w",encoding="utf-8") as f: + f.write(printer) + except: + pass self.close() printerOpenProperties(printer) printerOpenQueue(printer)