Example #1
0
    def set_color(self, color):
        if not color:
            self.qtcolor = None
            self.color = None
            Colors.set_widget_color(
                self.change_color_button,
                Colors.BUTTON_ORIGINAL,
                QtImport.QPalette.Button,
            )
        else:
            try:
                rgb = color.rgb()
            except BaseException:
                try:
                    self.qtcolor = QtImport.QColor(color)
                except BaseException:
                    self.qtcolor = QtImport.QtColor(QtImport.Qt.green)
                    self.color = self.qtcolor.rgb()
                else:
                    self.color = self.qtcolor.rgb()
            else:
                self.qtcolor = color
                self.color = rgb

            Colors.set_widget_color(
                self.change_color_button, self.qtcolor, QtImport.QPalette.Button
            )
        self.parent.cellChanged.emit(self.row, self.col)
Example #2
0
 def transmission_state_changed(self, transmission_state):
     """Updates new value QLineEdit based on the state"""
     Colors.set_widget_color(
         self.new_value_ledit,
         self.STATES.get(transmission_state, Colors.LIGHT_GRAY),
         QtImport.QPalette.Base,
     )
Example #3
0
    def _folder_ledit_change(self, new_value):
        base_image_dir = self._base_image_dir
        base_proc_dir = self._base_process_dir
        new_sub_dir = str(new_value).strip(" ")

        cursor_pos = self.data_path_layout.folder_ledit.cursorPosition()
        if len(new_value) > 0:
            available_chars = (
                string.ascii_lowercase + string.ascii_uppercase + string.digits + "-_/"
            )
            if self.enable_macros:
                available_chars += "%"
            new_value = "".join(i for i in str(new_value) if i in available_chars)
            # new_value = new_value.replace("\\", "")

        new_sub_dir = str(new_value).strip(" ")
        self.data_path_layout.folder_ledit.setText(new_value)
        self.data_path_layout.folder_ledit.setCursorPosition(cursor_pos)

        if len(new_sub_dir) > 0:
            if new_sub_dir[0] == os.path.sep:
                new_sub_dir = new_sub_dir[1:]
            new_image_directory = os.path.join(base_image_dir, str(new_sub_dir))
            new_proc_dir = os.path.join(base_proc_dir, str(new_sub_dir))
        else:
            new_image_directory = base_image_dir
            new_proc_dir = base_proc_dir

        self._data_model.directory = new_image_directory
        self._data_model.process_directory = new_proc_dir
        Colors.set_widget_color(self.data_path_layout.folder_ledit, Colors.WHITE)

        self.pathTemplateChangedSignal.emit()
 def status_changed(self, status, status_message):
     if status:
         self.status_label.setText("<b>%s</b>" % status.title())
         Colors.set_widget_color(
             self.status_label,
             DetectorStatusBrick.DETECTOR_STATES.get(status, Colors.LIGHT_GRAY),
         )
         self.setToolTip(status_message)
Example #5
0
 def user_group_changed(self, value):
     if self.saved_group:
         msg = "User group changed, press set to apply change"
         logging.getLogger("GUI").warning(msg)
         Colors.set_widget_color(
             self.user_group_ledit, Colors.LINE_EDIT_CHANGED, QtImport.QPalette.Base
         )
     self.saved_group = False
 def step_edited(self, step):
     """Paints step combobox when value is edited
     """
     Colors.set_widget_color(
         self.step_cbox.lineEdit(),
         Colors.LINE_EDIT_CHANGED,
         QtImport.QPalette.Button,
     )
 def input_field_changed(self, input_field_text):
     if input_field_text == "":
         Colors.set_widget_color(
             self.new_value_ledit, Colors.LINE_EDIT_ACTIVE, QtImport.QPalette.Base
         )
     else:
         Colors.set_widget_color(
             self.new_value_ledit, Colors.LINE_EDIT_CHANGED, QtImport.QPalette.Base
         )
Example #8
0
 def centring_failed(self, method, centring_status):
     self.centre_button.command_failed()
     self.accept_button.setEnabled(True)
     if self.inside_data_collection:
         Colors.set_widget_color(self.accept_button, self.standard_color)
         self.reject_button.setEnabled(True)
         Colors.set_widget_color(self.reject_button, QtImport.Qt.red)
     else:
         self.reject_button.setEnabled(False)
Example #9
0
    def centring_successful(self, method, centring_status):
        self.centre_button.command_done()
        self.accept_button.setEnabled(True)
        self.reject_button.setEnabled(True)
        if self.inside_data_collection:
            Colors.set_widget_color(self.accept_button, Colors.LIGHT_GREEN)
            Colors.set_widget_color(self.reject_button, Colors.LIGHT_RED)

        self.setEnabled(True)
Example #10
0
    def login(self):
        self.saved_group = False
        Colors.set_widget_color(self.user_group_ledit, Colors.WHITE)
        self.user_group_ledit.setText("")
        self.setEnabled(False)

        if not self.login_as_user:
            prop_type = str(self.proposal_type_combox.currentText())
            prop_number = str(self.proposal_number_ledit.text())
            prop_password = str(self.proposal_password_ledit.text())
            self.proposal_password_ledit.setText("")

            if prop_type == "" and prop_number == "":
                if self.local_login_hwobj is None:
                    return self.refuse_login(False, "Local login not configured.")
                try:
                    locallogin_password = self.local_login_hwobj.password
                except AttributeError:
                    return self.refuse_login(False, "Local login not configured.")

                if prop_password != locallogin_password:
                    return self.refuse_login(None, "Invalid local login password.")

                now = time.strftime("%Y-%m-%d %H:%M:S")
                prop_dict = {"code": "", "number": "", "title": "", "proposalId": ""}
                ses_dict = {
                    "sessionId": "",
                    "startDate": now,
                    "endDate": now,
                    "comments": "",
                }
                try:
                    locallogin_person = self.local_login_hwobj.person
                except AttributeError:
                    locallogin_person = "local user"
                pers_dict = {"familyName": locallogin_person}
                lab_dict = {"name": "local lab"}
                cont_dict = {"familyName": "local contact"}
                logging.getLogger().debug(
                    "ProposalBrick: local login password validated"
                )

                # return self.accept_login(prop_dict, pers_dict, lab_dict, ses_dict,
                # cont_dict)
                return self.accept_login(prop_dict, ses_dict)

            if api.lims is None:
                return self.refuse_login(
                    False,
                    "Not connected to the ISPyB database, unable to get proposal.",
                )

            self._do_login_as_proposal(
                prop_type, prop_number, prop_password, api.lims.beamline_name
            )
Example #11
0
    def __init__(self, *args):
        BaseWidget.__init__(self, *args)

        # Properties ----------------------------------------------------------
        self.add_property("hwobj_shutter", "string", "")

        # Signals -------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Hardware objects ----------------------------------------------------
        self.shutter_hwobj = None

        # Internal values -----------------------------------------------------

        # Graphic elements ----------------------------------------------------
        self.main_groupbox = QtImport.QGroupBox("Shutter", self)
        self.main_groupbox.setAlignment(QtImport.Qt.AlignCenter)
        self.state_label = QtImport.QLabel("<b>unknown</b>", self.main_groupbox)
        self.state_label.setAlignment(QtImport.Qt.AlignCenter)
        self.state_label.setFixedHeight(24)
        Colors.set_widget_color(self.state_label, Colors.LIGHT_GRAY)
        _button_widget = QtImport.QWidget(self.main_groupbox)

        self.open_button = QtImport.QPushButton(
            Icons.load_icon("ShutterOpen"), "Open", _button_widget
        )
        self.close_button = QtImport.QPushButton(
            Icons.load_icon("ShutterClose"), "Close", _button_widget
        )

        # Layout --------------------------------------------------------------
        _button_widget_hlayout = QtImport.QHBoxLayout(_button_widget)
        _button_widget_hlayout.addWidget(self.open_button)
        _button_widget_hlayout.addWidget(self.close_button)
        _button_widget_hlayout.setSpacing(2)
        _button_widget_hlayout.setContentsMargins(0, 0, 0, 0)

        _main_gbox_vlayout = QtImport.QVBoxLayout(self.main_groupbox)
        _main_gbox_vlayout.addWidget(self.state_label)
        _main_gbox_vlayout.addWidget(_button_widget)
        _main_gbox_vlayout.setSpacing(2)
        _main_gbox_vlayout.setContentsMargins(2, 2, 2, 2)

        _main_vlayout = QtImport.QVBoxLayout(self)
        _main_vlayout.addWidget(self.main_groupbox)
        _main_vlayout.setSpacing(0)
        _main_vlayout.setContentsMargins(0, 0, 0, 0)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.open_button.clicked.connect(self.open_button_clicked)
        self.close_button.clicked.connect(self.close_button_clicked)
Example #12
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------

        # Internal variables --------------------------------------------------

        # Properties ----------------------------------------------------------
        self.add_property("formatString", "formatString", "###.##")

        # Signals ------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        self.group_box = QtImport.QGroupBox("Transmission", self)
        current_label = QtImport.QLabel("Current:", self.group_box)
        current_label.setFixedWidth(75)
        self.transmission_ledit = QtImport.QLineEdit(self.group_box)
        self.transmission_ledit.setReadOnly(True)
        set_to_label = QtImport.QLabel("Set to:", self.group_box)
        self.new_value_ledit = QtImport.QLineEdit(self.group_box)

        # Layout --------------------------------------------------------------
        _group_box_gridlayout = QtImport.QGridLayout(self.group_box)
        _group_box_gridlayout.addWidget(current_label, 0, 0)
        _group_box_gridlayout.addWidget(self.transmission_ledit, 0, 1)
        _group_box_gridlayout.addWidget(set_to_label, 1, 0)
        _group_box_gridlayout.addWidget(self.new_value_ledit, 1, 1)
        _group_box_gridlayout.setSpacing(0)
        _group_box_gridlayout.setContentsMargins(1, 1, 1, 1)

        _main_vlayout = QtImport.QVBoxLayout(self)
        _main_vlayout.setSpacing(0)
        _main_vlayout.setContentsMargins(0, 0, 2, 2)
        _main_vlayout.addWidget(self.group_box)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.new_value_ledit.returnPressed.connect(self.current_value_changed)
        self.new_value_ledit.textChanged.connect(self.input_field_changed)

        # Other ---------------------------------------------------------------
        Colors.set_widget_color(
            self.new_value_ledit, Colors.LINE_EDIT_ACTIVE, QtImport.QPalette.Base
        )
        self.new_value_validator = QtImport.QDoubleValidator(
            0, 100, 2, self.new_value_ledit
        )
        self.new_value_ledit.setToolTip("Transmission limits 0 : 100 %")

        self.instance_synchronize("transmission_ledit", "new_value_ledit")
Example #13
0
 def connected(self):
     self.setEnabled(True)
     tunable_energy = api.energy.can_move_energy()
     if tunable_energy is None:
         tunable_energy = False
     self.set_to_label.setEnabled(tunable_energy)
     self.new_value_ledit.setEnabled(tunable_energy)
     self.units_combobox.setEnabled(tunable_energy)
     if tunable_energy:
         Colors.set_widget_color(
             self.new_value_ledit, Colors.LINE_EDIT_ACTIVE, QtImport.QPalette.Base
         )
Example #14
0
    def stateChanged(self, state, state_label=""):
        self.setEnabled(True)
        state = str(state)
        try:
            color = self.STATES[state][0]
        except KeyError:
            state = "unknown"
            color = self.STATES[state][0]
        if color is None:
            color = Colors.GROUP_BOX_GRAY

        Colors.set_widget_color(self.state_ledit, color, QtImport.QPalette.Base)
        # self.state_ledit.setPaletteBackgroundColor(QColor(color))
        if len(state_label) > 0:
            self.state_ledit.setText("%s" % state_label)
        else:
            label_str = state
            if state == "in":
                prop_label = self["in"].strip()
                if len(prop_label.strip()):
                    label_str = prop_label
            if state == "out":
                prop_label = self["out"].strip()
                if prop_label:
                    label_str = prop_label
            self.state_ledit.setText("%s" % label_str)

        if state in self.STATES:
            in_enable = self.STATES[state][1]
            out_enable = self.STATES[state][2]
        else:
            in_enable = False
            out_enable = False

        self.set_in_button.setEnabled(in_enable)
        self.set_out_button.setEnabled(out_enable)

        if state in self.STATES:
            in_state = self.STATES[state][3]
            out_state = self.STATES[state][4]
        else:
            in_state = True
            out_state = False
        if in_state is not None:
            self.set_in_button.blockSignals(True)
            self.set_in_button.setChecked(in_state)
            self.set_in_button.blockSignals(False)
        if out_state is not None:
            self.set_out_button.blockSignals(True)
            self.set_out_button.setChecked(out_state)
            self.set_out_button.blockSignals(False)

        """
Example #15
0
    def _run_number_ledit_change(self, new_value):
        if str(new_value).isdigit():
            self._data_model.run_number = int(new_value)
            self.data_path_layout.run_number_ledit.setText(str(new_value))

            self.update_file_name()
            self.pathTemplateChangedSignal.emit()
        else:
            # self.data_path_layout.run_number_ledit.setText(str(self._data_model.run_number))
            Colors.set_widget_color(
                self.data_path_layout.folder_ledit, Colors.LIGHT_YELLOW
            )
Example #16
0
 def input_field_changed(self, input_field_text):
     if (
         self.new_value_validator.validate(input_field_text, 0)[0]
         == QtImport.QValidator.Acceptable
     ):
         Colors.set_widget_color(
             self.new_value_ledit, Colors.LINE_EDIT_CHANGED, QtImport.QPalette.Base
         )
     else:
         Colors.set_widget_color(
             self.new_value_ledit, Colors.LINE_EDIT_ERROR, QtImport.QPalette.Base
         )
 def temperature_changed(self, value, status_ok):
     if value is not None:
         unit = u"\N{DEGREE SIGN}"
         self.temperature_label.setText("   Temperature : %0.1f%s" % (value, unit))
     if status_ok:
         Colors.set_widget_color(
             self.temperature_label, DetectorStatusBrick.STATES["OK"]
         )
     else:
         Colors.set_widget_color(
             self.temperature_label, DetectorStatusBrick.STATES["BAD"]
         )
Example #18
0
    def current_value_changed(self):
        """Sets new transmission value"""
        input_field_text = self.new_value_ledit.text()

        if (
            self.new_value_validator.validate(input_field_text, 0)[0]
            == QtImport.QValidator.Acceptable
        ):
            api.transmission.set_value(float(input_field_text))
            self.new_value_ledit.setText("")
            Colors.set_widget_color(
                self.new_value_ledit, Colors.LINE_EDIT_ACTIVE, QtImport.QPalette.Base
            )
 def humidity_changed(self, value, status_ok):
     if value is not None:
         self.humidity_label.setText(
             "   Humidity         : %0.1f%s" % (value, chr(37))
         )
     if status_ok:
         Colors.set_widget_color(
             self.humidity_label, DetectorStatusBrick.STATES["OK"]
         )
     else:
         Colors.set_widget_color(
             self.humidity_label, DetectorStatusBrick.STATES["BAD"]
         )
Example #20
0
 def input_field_changed(self, input_field_text):
     """Paints the QLineEdit green if entered values is acceptable"""
     if (
         self.new_value_validator.validate(input_field_text, 0)[0]
         == QtImport.QValidator.Acceptable
     ):
         Colors.set_widget_color(
             self.new_value_ledit, Colors.LINE_EDIT_CHANGED, QtImport.QPalette.Base
         )
     else:
         Colors.set_widget_color(
             self.new_value_ledit, Colors.LINE_EDIT_ERROR, QtImport.QPalette.Base
         )
Example #21
0
    def state_changed(self, state, state_label=None):
        try:
            color = self.STATES[state]
        except KeyError:
            state = "unknown"
            color = self.STATES[state]
        Colors.set_widget_color(self.state_label, color)
        if state_label is not None:
            self.state_label.setText("<b>%s</b>" % state_label)
        else:
            self.state_label.setText("<b>%s</b>" % state)

        self.unlock_door_button.setEnabled(state == "locked_active")
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)
        self.logger = logging.getLogger("GUI Alba Actuator")
        self.logger.info("__init__()")

        self.on_color = Colors.color_to_hexa(Colors.LIGHT_GREEN)
        self.off_color = Colors.color_to_hexa(Colors.LIGHT_GRAY)
        self.fault_color = Colors.color_to_hexa(Colors.LIGHT_RED)
        self.unknown_color = Colors.color_to_hexa(
            Colors.DARK_GRAY
        )

        # Hardware objects ----------------------------------------------------
        self.light_ho = None

        self.state = None
        self.level = None
        self.icons = None
        self.level_limits = [None, None]

        # Properties ----------------------------------------------------------
        self.add_property("mnemonic", "string", "")
        self.add_property("icons", "string", "")

        # Graphic elements ----------------------------------------------------
        self.widget = QtImport.load_ui_file("alba_lightcontrol.ui")

        QtImport.QHBoxLayout(self)

        self.layout().addWidget(self.widget)
        self.layout().setContentsMargins(0, 0, 0, 0)
        self.widget.layout().setContentsMargins(0, 0, 0, 0)
        self.widget.horizontalLayout.setContentsMargins(0, 0, 0, 0)

        self.widget.button.clicked.connect(self.do_switch)
        self.widget.slider.valueChanged.connect(self.do_set_level)

        # SizePolicies --------------------------------------------------------
        self.setSizePolicy(
            QtImport.QSizePolicy.Expanding, QtImport.QSizePolicy.MinimumExpanding
        )

        # Defaults
        self.set_icons("BulbCheck,BulbDelete")

        # Other ---------------------------------------------------------------
        self.setToolTip("Control of light (set level and on/off switch.")

        self.update()
    def diffractometer_state_changed(self, state):
        if self.diffractometer_hwobj.in_plate_mode():
            self.setDisabled(True)
            return

        if state == "Ready":
            self.kappa_dspinbox.setEnabled(True)
            self.kappaphi_dspinbox.setEnabled(True)
            self.close_button.setEnabled(True)
            self.stop_button.setEnabled(False)
            Colors.set_widget_color(
                self.kappa_dspinbox.lineEdit(),
                Colors.LIGHT_GREEN,
                QtImport.QPalette.Base,
            )
            Colors.set_widget_color(
                self.kappaphi_dspinbox.lineEdit(),
                Colors.LIGHT_GREEN,
                QtImport.QPalette.Base,
            )
        else:
            self.kappa_dspinbox.setEnabled(False)
            self.kappaphi_dspinbox.setEnabled(False)
            self.close_button.setEnabled(False)
            self.stop_button.setEnabled(True)
            Colors.set_widget_color(
                self.kappa_dspinbox.lineEdit(),
                Colors.LIGHT_YELLOW,
                QtImport.QPalette.Base,
            )
            Colors.set_widget_color(
                self.kappaphi_dspinbox.lineEdit(),
                Colors.LIGHT_YELLOW,
                QtImport.QPalette.Base,
            )
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

        # Internal variables --------------------------------------------------

        # Properties ----------------------------------------------------------

        # Signals ------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        _main_groupbox = QtImport.QGroupBox("Detector status", self)
        self.status_label = QtImport.QLabel("<b>unknown status</b>", _main_groupbox)
        self.frame_rate_label = QtImport.QLabel("   Frame rate     : ", _main_groupbox)
        self.temperature_label = QtImport.QLabel("   Temperature:", _main_groupbox)
        self.humidity_label = QtImport.QLabel("   Humidity:     ", _main_groupbox)

        # Layout --------------------------------------------------------------
        _main_groupbox_vlayout = QtImport.QVBoxLayout(_main_groupbox)
        _main_groupbox_vlayout.addWidget(self.status_label)
        _main_groupbox_vlayout.addWidget(self.frame_rate_label)
        _main_groupbox_vlayout.addWidget(self.temperature_label)
        _main_groupbox_vlayout.addWidget(self.humidity_label)
        _main_groupbox_vlayout.setSpacing(2)
        _main_groupbox_vlayout.setContentsMargins(4, 4, 4, 4)

        main_layout = QtImport.QVBoxLayout(self)
        main_layout.addWidget(_main_groupbox)
        main_layout.setSpacing(0)
        main_layout.setContentsMargins(0, 0, 0, 0)

        # SizePolicies -------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------

        # Other ---------------------------------------------------------------
        Colors.set_widget_color(
            self.status_label, DetectorStatusBrick.DETECTOR_STATES["uninitialized"]
        )
        Colors.set_widget_color(
            self.temperature_label, DetectorStatusBrick.STATES["unknown"]
        )
        Colors.set_widget_color(
            self.humidity_label, DetectorStatusBrick.STATES["unknown"]
        )
        Colors.set_widget_color(self.frame_rate_label, DetectorStatusBrick.STATES["OK"])

        self.status_label.setMinimumHeight(20)
        self.status_label.setAlignment(QtImport.Qt.AlignCenter)
        self.temperature_label.setMinimumHeight(20)
        self.humidity_label.setMinimumHeight(20)
        self.frame_rate_label.setMinimumHeight(20)

        self.connect(api.detector, "temperatureChanged", self.temperature_changed)
        self.connect(api.detector, "humidityChanged", self.humidity_changed)
        self.connect(api.detector, "statusChanged", self.status_changed)
        self.connect(api.detector, "frameRateChanged", self.frame_rate_changed)
Example #25
0
    def __init__(self, *args):
        BaseWidget.__init__(self, *args)

        # Properties ----------------------------------------------------------

        # Signals ------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Hardware objects ----------------------------------------------------

        # Internal values -----------------------------------------------------

        # Graphic elements ----------------------------------------------------
        self.main_groupbox = QtImport.QGroupBox("Door interlock", self)
        self.main_groupbox.setAlignment(QtImport.Qt.AlignCenter)
        self.state_label = QtImport.QLabel("<b>unknown</b>", self.main_groupbox)
        Colors.set_widget_color(self.state_label, self.STATES["unknown"])
        self.state_label.setAlignment(QtImport.Qt.AlignCenter)
        self.state_label.setFixedHeight(24)
        self.unlock_door_button = QtImport.QPushButton(
            Icons.load_icon("EnterHutch"), "Unlock", self.main_groupbox
        )

        # Layout --------------------------------------------------------------
        _main_gbox_vlayout = QtImport.QVBoxLayout(self.main_groupbox)
        _main_gbox_vlayout.addWidget(self.state_label)
        _main_gbox_vlayout.addWidget(self.unlock_door_button)
        _main_gbox_vlayout.setSpacing(2)
        _main_gbox_vlayout.setContentsMargins(4, 4, 4, 4)

        _main_vlayout = QtImport.QVBoxLayout(self)
        _main_vlayout.addWidget(self.main_groupbox)
        _main_vlayout.setSpacing(0)
        _main_vlayout.setContentsMargins(0, 0, 0, 0)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.unlock_door_button.clicked.connect(self.unlock_doors)

        # Other ---------------------------------------------------------------
        self.state_label.setToolTip("Shows the current door state")
        self.unlock_door_button.setToolTip("Unlocks the doors")

        self.connect(
            api.door_interlock, "doorInterlockStateChanged", self.state_changed
        )
        api.door_interlock.update_values()
Example #26
0
    def setState(self, state):

        logging.getLogger().debug("SC StatusView. State changed %s" % str(state))
        color = sc_helper.SC_STATE_COLOR.get(state, None)

        if color is None:
            color = Colors.LINE_EDIT_ORIGINAL

        Colors.set_widget_color(self.status_label, color)

        enabled = sc_helper.SC_STATE_GENERAL.get(state, False)
        self.status_label.setEnabled(enabled)
        state_str = sc_helper.SampleChangerState.tostring(state)
        self.status_label.setText(state_str)
        self._parent.set_status_info("sc", state_str)
Example #27
0
    def populate_widget(self, item):
        dcg_queue_item = item.get_queue_entry()

        dcg_child_list = []
        sw_list = []

        if dcg_queue_item.interleave_sw_list:
            sw_list = dcg_queue_item.interleave_sw_list
            for child in dcg_queue_item.interleave_items:
                dcg_child_list.append(child["data_model"])
        else:
            for children in dcg_queue_item.get_queue_entry_list():
                if isinstance(children.get_view(), queue_item.DataCollectionQueueItem):
                    dcg_child_list.append(children.get_data_model())
                    acq_par = (
                        children.get_data_model().acquisitions[0].acquisition_parameters
                    )
                    sw_list.append(
                        [
                            len(sw_list),
                            0,
                            acq_par.first_image,
                            acq_par.num_images,
                            acq_par.osc_start,
                            acq_par.osc_range * acq_par.num_images,
                        ]
                    )

        for sw in sw_list:
            color = Colors.get_random_numpy_color()
            sw.append(color)

        self.subwedge_table.setRowCount(0)
        for sw in sw_list:
            acq_par = dcg_child_list[sw[0]].acquisitions[0].acquisition_parameters
            row = self.subwedge_table.rowCount()
            self.subwedge_table.setRowCount(row + 1)
            param_list = (
                str(acq_par.osc_start),
                str(acq_par.osc_range),
                str(acq_par.num_images),
                str(acq_par.exp_time),
                str(acq_par.energy),
                str(acq_par.transmission),
                str(acq_par.resolution),
            )
            # color = Colors.get_random_color()
            # sw.append(color)
            for col in range(7):
                self.subwedge_table.setItem(
                    row, col, QtImport.QTableWidgetItem(param_list[col])
                )
                color = QtImport.QColor(
                    int(sw[-1][0] * 255), int(sw[-1][0] * 255), int(sw[-1][0] * 255)
                )
                color.setAlpha(100)
                self.subwedge_table.item(row, col).setBackground(color)
                #     QtGui.QColor(Colors.TASK_GROUP[sw[0]]))

        self.polar_scater_widget.draw_multiwedge_scater(sw_list)
Example #28
0
    def current_value_changed(self):
        input_field_text = self.new_value_ledit.text()

        if (
            self.new_value_validator.validate(input_field_text, 0)[0]
            == QtImport.QValidator.Acceptable
        ):
            if self.units_combobox.currentIndex() == 0:
                BaseWidget.set_status_info("status", "Setting energy...", "running")
                api.energy.move_energy(float(input_field_text))
            else:
                api.energy.move_wavelength(float(input_field_text))
            self.new_value_ledit.setText("")
            Colors.set_widget_color(
                self.new_value_ledit, Colors.LINE_EDIT_ACTIVE, QtImport.QPalette.Base
            )
    def state_changed(self, state, state_label=None):
        color = None
        try:
            color = self.STATES[state]
        except KeyError:
            state = "unknown"
            color = self.STATES[state]
        # if color is None:
        #    color = qt.QWidget.paletteBackgroundColor(self)

        if color:
            Colors.set_widget_color(self.state_label, color)
        if state_label is not None:
            self.state_label.setText("<b>%s</b>" % state_label)
        else:
            self.state_label.setText("<b>%s</b>" % state)
Example #30
0
    def current_value_changed(self):
        input_field_text = self.new_value_ledit.text()

        if (
            self.new_value_validator.validate(input_field_text, 0)[0]
            == QtImport.QValidator.Acceptable
        ):
            unit = self.units_combobox.currentText()
            value = float()
            self.new_value_ledit.setText("")
            if unit == chr(197):
                self.set_resolution(float(input_field_text))
            elif unit == "mm":
                self.set_detector_distance(float(input_field_text))
            Colors.set_widget_color(
                self.new_value_ledit, Colors.LINE_EDIT_ACTIVE, QtImport.QPalette.Base
            )
Example #31
0
 def set_position_spinbox_color(self, state):
     """Changes color of the spinbox based on the state"""
     color = MotorSpinBoxBrick.STATE_COLORS[state]
     Colors.set_widget_color(
         self.position_spinbox.lineEdit(), color, QtImport.QPalette.Base
     )
Example #32
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

        # Properties ----------------------------------------------------------
        self.add_property("defaultMode", "combo", ("keV", "Ang"), "keV")
        self.add_property("kevFormatString", "formatString", "##.####")
        self.add_property("angFormatString", "formatString", "##.####")
        self.add_property("displayStatus", "boolean", False)
        self.add_property("doBeamAlignment", "boolean", False)

        # Signals ------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Hardware objects ----------------------------------------------------

        # Internal values -----------------------------------------------------

        # Graphic elements ----------------------------------------------------
        self.group_box = QtImport.QGroupBox("Energy", self)
        energy_label = QtImport.QLabel("Current:", self.group_box)
        energy_label.setFixedWidth(75)
        wavelength_label = QtImport.QLabel("Wavelength: ", self.group_box)
        self.energy_ledit = QtImport.QLineEdit(self.group_box)
        self.energy_ledit.setReadOnly(True)
        self.wavelength_ledit = QtImport.QLineEdit(self.group_box)
        self.wavelength_ledit.setReadOnly(True)

        self.status_label = QtImport.QLabel("Status:", self.group_box)
        self.status_label.setEnabled(False)
        self.status_ledit = QtImport.QLineEdit(self.group_box)
        self.status_ledit.setEnabled(False)

        self.new_value_widget = QtImport.QWidget(self)
        self.set_to_label = QtImport.QLabel("Set to: ", self)
        self.new_value_ledit = QtImport.QLineEdit(self.new_value_widget)
        # self.new_value_ledit.setMaximumWidth(60)
        self.units_combobox = QtImport.QComboBox(self.new_value_widget)
        self.units_combobox.addItems(["keV", u"\u212B"])
        self.stop_button = QtImport.QPushButton(self.new_value_widget)
        self.stop_button.setIcon(Icons.load_icon("Stop2"))
        self.stop_button.setEnabled(False)
        self.stop_button.setFixedWidth(25)

        self.beam_align_cbox = QtImport.QCheckBox(
            "Center beam after energy change", self
        )

        # Layout --------------------------------------------------------------
        _new_value_widget_hlayout = QtImport.QHBoxLayout(self.new_value_widget)
        _new_value_widget_hlayout.addWidget(self.new_value_ledit)
        _new_value_widget_hlayout.addWidget(self.units_combobox)
        _new_value_widget_hlayout.addWidget(self.stop_button)
        _new_value_widget_hlayout.setSpacing(0)
        _new_value_widget_hlayout.setContentsMargins(0, 0, 0, 0)

        _group_box_gridlayout = QtImport.QGridLayout(self.group_box)
        _group_box_gridlayout.addWidget(energy_label, 0, 0)
        _group_box_gridlayout.addWidget(self.energy_ledit, 0, 1)
        _group_box_gridlayout.addWidget(wavelength_label, 1, 0)
        _group_box_gridlayout.addWidget(self.wavelength_ledit, 1, 1)
        _group_box_gridlayout.addWidget(self.status_label, 2, 0)
        _group_box_gridlayout.addWidget(self.status_ledit, 2, 1)
        _group_box_gridlayout.addWidget(self.set_to_label, 3, 0)
        _group_box_gridlayout.addWidget(self.new_value_widget, 3, 1)
        _group_box_gridlayout.addWidget(self.beam_align_cbox, 4, 0, 1, 2)

        _group_box_gridlayout.setSpacing(0)
        _group_box_gridlayout.setContentsMargins(1, 1, 1, 1)

        _main_vlayout = QtImport.QVBoxLayout(self)
        _main_vlayout.setSpacing(0)
        _main_vlayout.setContentsMargins(0, 0, 2, 2)
        _main_vlayout.addWidget(self.group_box)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.new_value_ledit.returnPressed.connect(self.current_value_changed)
        self.new_value_ledit.textChanged.connect(self.input_field_changed)
        self.units_combobox.activated.connect(self.units_changed)
        self.stop_button.clicked.connect(self.stop_clicked)
        self.beam_align_cbox.stateChanged.connect(self.do_beam_align_changed)

        # Other ---------------------------------------------------------------
        # self.group_box.setCheckable(True)
        # self.group_box.setChecked(True)
        self.new_value_validator = QtImport.QDoubleValidator(
            0, 15, 4, self.new_value_ledit
        )
        self.status_ledit.setEnabled(False)

        self.set_new_value_limits()
        self.connect(HWR.beamline.energy, "valueChanged", self.energy_changed)
        self.connect(HWR.beamline.energy, "stateChanged", self.state_changed)
        self.connect(
            HWR.beamline.energy, "statusInfoChanged", self.status_info_changed
        )

        if hasattr(HWR.beamline.energy, "set_do_beam_alignment"):
            HWR.beamline.energy.set_do_beam_alignment(self["doBeamAlignment"])

        if HWR.beamline.energy.is_ready():
            tunable_energy = HWR.beamline.energy.is_tunable
            if tunable_energy is None:
                tunable_energy = False
            self.set_to_label.setEnabled(tunable_energy)
            self.new_value_ledit.setEnabled(tunable_energy)
            self.units_combobox.setEnabled(tunable_energy)
            if tunable_energy:
                Colors.set_widget_color(
                    self.new_value_ledit, Colors.LINE_EDIT_ACTIVE, QtImport.QPalette.Base
                )
        else:
            self.setEnabled(False)
        
        self.instance_synchronize("energy_ledit", "new_value_ledit")
Example #33
0
 def set_background_color(self, color):
     Colors.set_widget_color(self, color, QtImport.QPalette.Background)
Example #34
0
 def command_done(self):
     self.executing = False
     Colors.set_widget_color(self, self.standard_color, QtImport.QPalette.Button)
     if self.run_icon is not None:
         self.setIcon(self.run_icon)
     self.setEnabled(True)
Example #35
0
 def ver_gap_edited(self, text):
     Colors.set_widget_color(
         self.ver_pos_dspinbox.lineEdit(),
         Colors.LINE_EDIT_CHANGED,
         QtImport.QPalette.Base,
     )
Example #36
0
 def _update_ledit_color(self, color):
     Colors.set_widget_color(self.new_value_ledit, color,
                             QtImport.QPalette.Base)
Example #37
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

        # Internal values -----------------------------------------------------
        self.resolution_limits = None
        self.detector_distance_limits = None
        self.door_interlocked = True

        # Properties ----------------------------------------------------------
        self.add_property("defaultMode", "combo", ("Ang", "mm"), "Ang")
        self.add_property("mmFormatString", "formatString", "###.##")
        self.add_property("angFormatString", "formatString", "##.###")

        self.group_box = QtImport.QGroupBox("Resolution", self)
        current_label = QtImport.QLabel("Current:", self.group_box)
        current_label.setFixedWidth(75)

        self.resolution_ledit = QtImport.QLineEdit(self.group_box)
        self.resolution_ledit.setReadOnly(True)
        self.detector_distance_ledit = QtImport.QLineEdit(self.group_box)
        self.detector_distance_ledit.setReadOnly(True)

        _new_value_widget = QtImport.QWidget(self)
        set_to_label = QtImport.QLabel("Set to:", self.group_box)
        self.new_value_ledit = QtImport.QLineEdit(self.group_box)
        self.units_combobox = QtImport.QComboBox(_new_value_widget)
        self.stop_button = QtImport.QPushButton(_new_value_widget)
        self.stop_button.setIcon(Icons.load_icon("Stop2"))
        self.stop_button.setEnabled(False)
        self.stop_button.setFixedWidth(25)

        # Layout --------------------------------------------------------------
        _new_value_widget_hlayout = QtImport.QHBoxLayout(_new_value_widget)
        _new_value_widget_hlayout.addWidget(self.new_value_ledit)
        _new_value_widget_hlayout.addWidget(self.units_combobox)
        _new_value_widget_hlayout.addWidget(self.stop_button)
        _new_value_widget_hlayout.setSpacing(0)
        _new_value_widget_hlayout.setContentsMargins(0, 0, 0, 0)

        _group_box_gridlayout = QtImport.QGridLayout(self.group_box)
        _group_box_gridlayout.addWidget(current_label, 0, 0, 2, 1)
        _group_box_gridlayout.addWidget(self.resolution_ledit, 0, 1)
        _group_box_gridlayout.addWidget(self.detector_distance_ledit, 1, 1)
        _group_box_gridlayout.addWidget(set_to_label, 2, 0)
        _group_box_gridlayout.addWidget(_new_value_widget, 2, 1)
        _group_box_gridlayout.setSpacing(0)
        _group_box_gridlayout.setContentsMargins(1, 1, 1, 1)

        _main_vlayout = QtImport.QVBoxLayout(self)
        _main_vlayout.setSpacing(0)
        _main_vlayout.setContentsMargins(0, 0, 2, 2)
        _main_vlayout.addWidget(self.group_box)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.new_value_ledit.returnPressed.connect(self.current_value_changed)
        self.new_value_ledit.textChanged.connect(self.input_field_changed)
        self.units_combobox.activated.connect(self.unit_changed)
        self.stop_button.clicked.connect(self.stop_clicked)

        # Other ---------------------------------------------------------------
        Colors.set_widget_color(self.new_value_ledit, Colors.LINE_EDIT_ACTIVE,
                                QtImport.QPalette.Base)
        self.new_value_validator = QtImport.QDoubleValidator(
            0, 15, 4, self.new_value_ledit)

        self.units_combobox.addItem(chr(197))
        self.units_combobox.addItem("mm")
        self.instance_synchronize(
            "group_box",
            "resolution_ledit",
            "detector_distance_ledit",
            "new_value_ledit",
            "units_combobox",
        )
Example #38
0
 def reject_clicked(self):
     Colors.set_widget_color(self.accept_button, self.standard_color)
     self.reject_button.setEnabled(False)
     self.centre_button.setEnabled(True)
     self.accept_button.setEnabled(True)
     HWR.beamline.sample_view.reject_centring()
Example #39
0
 def step_changed(self, step):
     Colors.set_widget_color(
         self.step_cbox.lineEdit(), QtImport.Qt.white, QtImport.QPalette.Base
     )
Example #40
0
 def kappaphi_value_edited(self, text):
     Colors.set_widget_color(
         self.kappaphi_dspinbox.lineEdit(),
         Colors.LINE_EDIT_CHANGED,
         QtImport.QPalette.Base,
     )
Example #41
0
    def property_changed(self, property_name, old_value, new_value):
        if property_name == "label":
            if new_value == "" and self.motor_hwobj is not None:
                self.label.setText("<i>" + self.motor_hwobj.username + ":</i>")
            else:
                self.label.setText(new_value)
        elif property_name == "mnemonic":
            if self.motor_hwobj is not None:
                self.disconnect(self.motor_hwobj, "stateChanged",
                                self.motor_state_changed)
                self.disconnect(self.motor_hwobj, "newPredefinedPositions",
                                self.fill_positions)
                self.disconnect(
                    self.motor_hwobj,
                    "predefinedPositionChanged",
                    self.predefined_position_changed,
                )

            self.motor_hwobj = self.get_hardware_object(new_value)

            if self.motor_hwobj is not None:
                self.connect(self.motor_hwobj, "newPredefinedPositions",
                             self.fill_positions)
                self.connect(self.motor_hwobj, "stateChanged",
                             self.motor_state_changed)
                self.connect(
                    self.motor_hwobj,
                    "predefinedPositionChanged",
                    self.predefined_position_changed,
                )
                self.fill_positions()
                if self.motor_hwobj.is_ready():
                    self.predefined_position_changed(
                        self.motor_hwobj.get_value(), 0)
                if self["label"] == "":
                    lbl = self.motor_hwobj.user_name
                    self.label.setText("<i>" + lbl + ":</i>")
                Colors.set_widget_color(
                    self.positions_combo,
                    MotorPredefPosBrick.STATE_COLORS[0],
                    QtImport.QPalette.Button,
                )
                self.motor_state_changed(self.motor_hwobj.get_state())
        elif property_name == "showMoveButtons":
            if new_value:
                self.previous_position_button.show()
                self.next_position_button.show()
            else:
                self.previous_position_button.hide()
                self.next_position_button.hide()
        elif property_name == "icons":
            icons_list = new_value.split()
            try:
                self.previous_position_button.setIcon(
                    Icons.load_icon(icons_list[0]))
                self.next_position_button.setIcon(
                    Icons.load_icon(icons_list[1]))
            except BaseException:
                pass
        else:
            BaseWidget.property_changed(self, property_name, old_value,
                                        new_value)
Example #42
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

        # Internal variables --------------------------------------------------

        # Properties ----------------------------------------------------------

        # Signals ------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        _main_groupbox = QtImport.QGroupBox("Detector status", self)
        self.status_label = QtImport.QLabel("<b>unknown status</b>",
                                            _main_groupbox)
        self.frame_rate_label = QtImport.QLabel("   Frame rate     : ",
                                                _main_groupbox)
        self.temperature_label = QtImport.QLabel("   Temperature:",
                                                 _main_groupbox)
        self.humidity_label = QtImport.QLabel("   Humidity:     ",
                                              _main_groupbox)

        # Layout --------------------------------------------------------------
        _main_groupbox_vlayout = QtImport.QVBoxLayout(_main_groupbox)
        _main_groupbox_vlayout.addWidget(self.status_label)
        _main_groupbox_vlayout.addWidget(self.frame_rate_label)
        _main_groupbox_vlayout.addWidget(self.temperature_label)
        _main_groupbox_vlayout.addWidget(self.humidity_label)
        _main_groupbox_vlayout.setSpacing(2)
        _main_groupbox_vlayout.setContentsMargins(4, 4, 4, 4)

        main_layout = QtImport.QVBoxLayout(self)
        main_layout.addWidget(_main_groupbox)
        main_layout.setSpacing(0)
        main_layout.setContentsMargins(0, 0, 0, 0)

        # SizePolicies -------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------

        # Other ---------------------------------------------------------------
        Colors.set_widget_color(
            self.status_label,
            DetectorStatusBrick.DETECTOR_STATES["uninitialized"])
        Colors.set_widget_color(self.temperature_label,
                                DetectorStatusBrick.STATES["unknown"])
        Colors.set_widget_color(self.humidity_label,
                                DetectorStatusBrick.STATES["unknown"])
        Colors.set_widget_color(self.frame_rate_label,
                                DetectorStatusBrick.STATES["OK"])

        self.status_label.setMinimumHeight(20)
        self.status_label.setAlignment(QtImport.Qt.AlignCenter)
        self.temperature_label.setMinimumHeight(20)
        self.humidity_label.setMinimumHeight(20)
        self.frame_rate_label.setMinimumHeight(20)

        self.connect(HWR.beamline.detector, "temperatureChanged",
                     self.temperature_changed)
        self.connect(HWR.beamline.detector, "humidityChanged",
                     self.humidity_changed)
        self.connect(HWR.beamline.detector, "statusChanged",
                     self.status_changed)
        self.connect(HWR.beamline.detector, "frameRateChanged",
                     self.frame_rate_changed)
Example #43
0
 def step_edited(self, step):
     Colors.set_widget_color(
         self.step_combo.lineEdit(),
         Colors.LINE_EDIT_CHANGED,
         QtImport.QPalette.Button,
     )
Example #44
0
 def position_value_edited(self, value):
     Colors.set_widget_color(
         self.position_spinbox.lineEdit(),
         QtImport.QColor(255, 165, 0),
         QtImport.QPalette.Base,
     )
Example #45
0
    def __init__(self, *args):
        """
        Proposal brick is used to authentificate current user.
        Brick can be used in two modes defined by ispyb hwobj
         - loginAsUser = True, Brick displays combobox with all
           proposals from ISPyB that are associated to the current user
         - loginAsUser = False. Brick displays combobox to choose proposal
           type and linedits to enter proposal number and password.
           In this case user is authentificated with
           LDAP and proposal from ISPyB is retrieved.
        """
        BaseWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------
        self.local_login_hwobj = None

        # Internal values -----------------------------------------------------
        self.login_as_user = None

        self.proposal = None
        self.session = None
        self.person = None
        self.laboratory = None
        # self.sessionId=None
        self.inhouseProposal = None
        self.instance_server_hwobj = None
        self.secondary_proposals = []

        # Properties ----------------------------------------------------------
        self.add_property("instanceServer", "string", "")
        self.add_property("localLogin", "string", "")
        self.add_property("titlePrefix", "string", "")
        self.add_property("autoSessionUsers", "string", "")
        self.add_property("codes", "string", "fx ifx ih im ix ls mx opid")
        self.add_property("secondaryProposals", "string", "")
        self.add_property("icons", "string", "")
        self.add_property("serverStartDelay", "integer", 500)
        self.add_property("dbConnection", "string")
        self.add_property("session", "string", "/session")

        # Signals ------------------------------------------------------------
        self.define_signal("sessionSelected", ())
        self.define_signal("setWindowTitle", ())
        self.define_signal("loggedIn", ())
        self.define_signal("userGroupSaved", ())

        # Slots ---------------------------------------------------------------
        self.define_slot("setButtonEnabled", ())
        self.define_slot("impersonateProposal", ())

        # Graphic elements ----------------------------------------------------
        self.main_gbox = QtImport.QGroupBox("ISPyB proposal", self)

        self.login_as_proposal_widget = QtImport.QWidget(self.main_gbox)
        code_label = QtImport.QLabel("  Code: ", self.login_as_proposal_widget)
        self.proposal_type_combox = QtImport.QComboBox(
            self.login_as_proposal_widget)
        self.proposal_type_combox.setEditable(True)
        self.proposal_type_combox.setFixedWidth(60)
        dash_label = QtImport.QLabel(" - ", self.login_as_proposal_widget)
        self.proposal_number_ledit = QtImport.QLineEdit(
            self.login_as_proposal_widget)
        self.proposal_number_ledit.setFixedWidth(60)
        password_label = QtImport.QLabel("   Password: "******"Login",
                                                 self.login_as_proposal_widget)
        self.login_button.setFixedWidth(70)
        self.logout_button = QtImport.QPushButton("Logout", self.main_gbox)
        self.logout_button.hide()
        self.logout_button.setFixedWidth(70)
        self.login_as_proposal_widget.hide()

        self.login_as_user_widget = QtImport.QWidget(self.main_gbox)
        self.proposal_combo = QtImport.QComboBox(self.login_as_user_widget)

        self.user_group_widget = QtImport.QWidget(self.main_gbox)
        # self.title_label = QtGui.QLabel(self.user_group_widget)
        # self.title_label.setAlignment(QtCore.Qt.AlignCenter)
        self.user_group_label = QtImport.QLabel("  Group: ",
                                                self.user_group_widget)
        self.user_group_ledit = QtImport.QLineEdit(self.user_group_widget)
        self.user_group_ledit.setFixedSize(100, 27)
        self.user_group_save_button = QtImport.QToolButton(
            self.user_group_widget)
        self.user_group_save_button.setText("Set")
        self.user_group_save_button.setFixedHeight(27)
        self.saved_group = True

        # Layout --------------------------------------------------------------
        _user_group_widget_hlayout = QtImport.QHBoxLayout(
            self.user_group_widget)
        _user_group_widget_hlayout.setSpacing(2)
        # _user_group_widget_hlayout.addWidget(self.title_label)
        _user_group_widget_hlayout.addWidget(self.user_group_label)
        _user_group_widget_hlayout.addWidget(self.user_group_ledit)
        _user_group_widget_hlayout.addWidget(self.user_group_save_button)
        _user_group_widget_hlayout.setContentsMargins(0, 0, 0, 0)
        self.user_group_widget.hide()

        _login_as_proposal_widget_layout = QtImport.QHBoxLayout(
            self.login_as_proposal_widget)
        _login_as_proposal_widget_layout.addWidget(code_label)
        _login_as_proposal_widget_layout.addWidget(self.proposal_type_combox)
        _login_as_proposal_widget_layout.addWidget(dash_label)
        _login_as_proposal_widget_layout.addWidget(self.proposal_number_ledit)
        _login_as_proposal_widget_layout.addWidget(password_label)
        _login_as_proposal_widget_layout.addWidget(
            self.proposal_password_ledit)
        _login_as_proposal_widget_layout.addWidget(self.login_button)
        _login_as_proposal_widget_layout.setSpacing(2)
        _login_as_proposal_widget_layout.setContentsMargins(0, 0, 0, 0)

        _login_as_user_widget_layout = QtImport.QHBoxLayout(
            self.login_as_user_widget)
        _login_as_user_widget_layout.addWidget(self.proposal_combo)
        _login_as_user_widget_layout.setSpacing(2)
        _login_as_user_widget_layout.setContentsMargins(0, 0, 0, 0)

        _main_gboxlayout = QtImport.QHBoxLayout(self.main_gbox)
        _main_gboxlayout.addWidget(self.login_as_proposal_widget)
        _main_gboxlayout.addWidget(self.logout_button)
        _main_gboxlayout.addWidget(self.login_as_user_widget)
        _main_gboxlayout.addStretch()
        _main_gboxlayout.addWidget(self.user_group_widget)
        _main_gboxlayout.setSpacing(2)
        _main_gboxlayout.setContentsMargins(0, 0, 0, 0)

        _main_vlayout = QtImport.QVBoxLayout(self)
        _main_vlayout.addWidget(self.main_gbox)
        _main_vlayout.setSpacing(2)
        _main_vlayout.setContentsMargins(2, 2, 2, 2)

        # SizePolicies --------------------------------------------------------
        #  self.user_group_ledit

        # Qt signal/slot connections ------------------------------------------
        self.proposal_password_ledit.returnPressed.connect(self.login)
        self.login_button.clicked.connect(self.login)
        self.logout_button.clicked.connect(self.logout_clicked)
        self.proposal_combo.activated.connect(self.proposal_combo_activated)
        self.user_group_save_button.clicked.connect(self.save_group)
        self.user_group_ledit.returnPressed.connect(self.save_group)
        self.user_group_ledit.textChanged.connect(self.user_group_changed)

        # Other ---------------------------------------------------------------
        Colors.set_widget_color(self.proposal_number_ledit, Colors.LIGHT_RED,
                                QtImport.QPalette.Base)
        Colors.set_widget_color(self.proposal_password_ledit, Colors.LIGHT_RED,
                                QtImport.QPalette.Base)
Example #46
0
    def indicate_path_conflict(self, conflict):
        if conflict:
            Colors.set_widget_color(
                self.data_path_layout.prefix_ledit,
                Colors.LIGHT_RED,
                QtImport.QPalette.Base,
            )
            Colors.set_widget_color(
                self.data_path_layout.run_number_ledit,
                Colors.LIGHT_RED,
                QtImport.QPalette.Base,
            )
            Colors.set_widget_color(
                self.data_path_layout.folder_ledit,
                Colors.LIGHT_RED,
                QtImport.QPalette.Base,
            )

            logging.getLogger(
                "GUI").error("The current path settings will overwrite data " +
                             "from another task. Correct the problem before " +
                             "adding to queue")
        else:
            # We had a conflict previous, but its corrected now !
            if self.path_conflict_state:
                logging.getLogger("GUI").info("Path valid")

                Colors.set_widget_color(
                    self.data_path_layout.prefix_ledit,
                    Colors.WHITE,
                    QtImport.QPalette.Base,
                )
                Colors.set_widget_color(
                    self.data_path_layout.run_number_ledit,
                    Colors.WHITE,
                    QtImport.QPalette.Base,
                )
                Colors.set_widget_color(
                    self.data_path_layout.folder_ledit,
                    Colors.WHITE,
                    QtImport.QPalette.Base,
                )
        self.path_conflict_state = conflict
Example #47
0
 def command_started(self):
     Colors.set_widget_color(self, Colors.LIGHT_YELLOW, QtImport.QPalette.Button)
     if self.stop_icon is not None:
         self.setIcon(self.stop_icon)
     self.executing = True
     self.setEnabled(True)
Example #48
0
    def __validated(self, field_name, validator, widget, new_value):
        if validator:
            try:
                flt_value = float(new_value)
            except BaseException:
                Colors.set_widget_color(widget, Colors.LIGHT_RED,
                                        QtImport.QPalette.Base)
                return False

            if flt_value >= min(validator.bottom(),
                                validator.top()) and flt_value <= max(
                                    validator.bottom(), validator.top()):
                # if validator.validate(new_value, widget.cursorPosition())[0] \
                #        == QValidator.Acceptable:
                if self.bindings[field_name][3]:
                    Colors.set_widget_color(widget, Colors.LIGHT_YELLOW,
                                            QtImport.QPalette.Base)
                else:
                    Colors.set_widget_color(widget, Colors.WHITE,
                                            QtImport.QPalette.Base)
                return True
            else:
                Colors.set_widget_color(widget, Colors.LIGHT_RED,
                                        QtImport.QPalette.Base)
                return False
        else:
            if self.bindings[field_name][3]:
                Colors.set_widget_color(widget, Colors.LIGHT_YELLOW,
                                        QtImport.QPalette.Base)
            else:
                Colors.set_widget_color(widget, Colors.WHITE,
                                        QtImport.QPalette.Base)
            return True