""" The Treatment End ui loader class """ # Python import os # Qt from PySide2 import QtWidgets from PySide2.QtCore import Slot # parent from simulator.dynamicloader import DynamicLoader # hd Simulator from dialin.ui.hd_simulator import HDSimulator # plugin specific # -- none -- class Loader(DynamicLoader): """ The Treatment End ui loader class """ btnAccept: QtWidgets.QPushButton btnReject: QtWidgets.QPushButton lblAction: QtWidgets.QLabel spnRejectReason: QtWidgets.QSpinBox def __init__(self, hd_simulator: HDSimulator): super().__init__(os.path.dirname(__file__), hd_simulator) def _init_loader(self): """ finds and creates widgets :return: none """ self.btnAccept = self.find_button('btnAccept') self.btnReject = self.find_button('btnReject') self.lblAction = self.find_label('lblAction') self.spnRejectReason = self.find_spinbox('spnRejectReason') def _init_widgets(self): """ initializes the widgets' properties :return: none """ pass def _init_connections(self): """ initializes the widgets connections :return: """ self.btnAccept.clicked.connect(self.do_accept) self.btnReject.clicked.connect(self.do_reject) @Slot() def do_accept(self): """ the slot for accept treatment end button :return: none """ self.hd_simulator.cmd_send_treatment_adjust_end_response(True, 0) self.lblAction.setText('Accepted ') @Slot() def do_reject(self): """ the slot for accept treatment end button :return: none """ reason = self.spnRejectReason.value() self.hd_simulator.cmd_send_treatment_adjust_end_response(False, reason) self.lblAction.setText('Rejected ' + "{}".format(reason))