Save last printer

This commit is contained in:
Fierelier 2023-08-23 13:55:19 +02:00
parent a75022195d
commit 67f30b55bb

View File

@ -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)