This commit is contained in:
2025-09-15 00:15:49 +03:00
commit 8c1647eb13
10 changed files with 258 additions and 0 deletions

38
config.py Normal file
View File

@@ -0,0 +1,38 @@
import json
import printer
class PrinterConfig:
editables = {"printer_address", "printer_port"}
required_params = {"printer_address"}
def __init__(self):
self.printer_address = None
self.printer_port = 9100
self.printer_profile = "RP-F10-80mm"
self.__printer = None
def save(self):
with open("config.json", "w", encoding="utf-8") as ofd:
json.dump(self.__dict__, ofd, ensure_ascii=False)
def load(self):
with open("config.json", "r", encoding="utf-8") as ifd:
self.__dict__ = json.load(ifd)
@property
def complete(self):
for param in self.required_params:
if getattr(self, param) is None:
return False
return True
@property
def printer(self):
if self.__printer is None:
self.__printer = printer.Printer(
address=self.printer_address,
port=self.printer_port,
profile=self.printer_profile,
)
return self.printer