Merge remote-tracking branch 'origin/master'

This commit is contained in:
matteo porta 2022-07-26 16:19:01 +02:00
commit 5bba17f5d3
5 changed files with 37 additions and 6 deletions

View File

@ -79,7 +79,10 @@ class Component(QObject):
self._set_sources.connect(self._do_set_sources) self._set_sources.connect(self._do_set_sources)
self._set_period.connect(self._do_set_period) self._set_period.connect(self._do_set_period)
if self.config is not None: if self.config is not None:
try:
self.config.updated.connect(self._config_changed) self.config.updated.connect(self._config_changed)
except AttributeError:
pass
self._config_changed() self._config_changed()
self._init_periodic() self._init_periodic()
self._started = True self._started = True

View File

@ -9,9 +9,10 @@ from .component import Component
class Os_Label_Printer(Component): class Os_Label_Printer(Component):
def __init__(self, config=None, name=None): def __init__(self, config=None, name=None):
super().__init__(config=config, name=name, threaded=False) super().__init__(config=config, name=name, threaded=False)
self.simulate = False
if "--sim-os-label-printer" in sys.argv: if "--sim-os-label-printer" in sys.argv:
self.simulate = True self.simulate = True
self.platform = "windows"
def config_changed(self): def config_changed(self):
self.platform = self.config[self.name]["platform"] self.platform = self.config[self.name]["platform"]
# for windows: # for windows:
@ -31,7 +32,7 @@ class Os_Label_Printer(Component):
label = f.read() label = f.read()
# LABEL PRINT # LABEL PRINT
label = label.format(**context) label = label.format(**context)
label_file = "/tmp/label.prn" label_file = "tmp/label.prn"
with open(label_file, "w", errors="surrogateescape") as f: with open(label_file, "w", errors="surrogateescape") as f:
label = f.write(label) label = f.write(label)
if self.platform == "windows": if self.platform == "windows":

View File

@ -152,10 +152,10 @@ try:
def open_login(self): def open_login(self):
tab = Login() tab = Login()
tab.successful_login.connect(self.logghed_in) tab.successful_login.connect(self.logged_in)
self.main_window.open_tab(tab) self.main_window.open_tab(tab)
def logghed_in(self): def logged_in(self):
session = Users.get_session() session = Users.get_session()
if session is not None: if session is not None:
if session.is_admin: if session.is_admin:

27
src/test/label_printer.py Normal file
View File

@ -0,0 +1,27 @@
from datetime import datetime
from components import Os_Label_Printer
dmtx="0AG554457062203314"
context = {
"DATAMATRIX": dmtx,
"DATAMATRIX_TEXT": dmtx,
"PIECE_NUM": str(3314),
"DATETIME": str(datetime.now().isoformat()),
"SHIFT": "01",
"STATION": "ST-TEN-1",
"OPERATOR": "albano",
"PMAX": "6,13",
"PMIN": "6,13",
"LEAK": "0,00",
"TFILL": "5",
"TSTAB": "10",
"TTEST": "20",
"MAXLEAK": "0,03",
"PTESTMIN": "6,00",
"RESULT_L1": "ESITO",
"RESULT_L2": "CONFORME",
}
config={"test":{"platform":"windows","printer":"zd421"}}
printer=Os_Label_Printer(config=config,name="test")
printer.print_label("EtichettaR5", context=context)

View File

@ -191,7 +191,7 @@
<item row="2" column="1"> <item row="2" column="1">
<widget class="QSpinBox" name="settling_pressure_min_percent_sb"> <widget class="QSpinBox" name="settling_pressure_min_percent_sb">
<property name="maximum"> <property name="maximum">
<number>100</number> <number>150</number>
</property> </property>
</widget> </widget>
</item> </item>