Esempio n. 1
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)
        self.logger = logging.getLogger("GUI MachineInfo")
        self.logger.info("__init__()")
        # Hardware objects ----------------------------------------------------
        self.mach_info_hwobj = None

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

        # Properties ----------------------------------------------------------
        self.add_property("mnemonic", "string", "")
        self.add_property("formatString", "formatString", "###.#")
        # self.addProperty('diskThreshold', 'float', '200')

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

        # Slots ---------------------------------------------------------------
        self.defineSlot("setColDir", ())

        # Graphic elements ----------------------------------------------------
        self.groupBox = qt_import.QGroupBox("Machine Info", self)
        _main_layout = qt_import.QVBoxLayout(self)
        _main_layout.addWidget(self.groupBox)
        _main_layout.setSpacing(1)
        _main_layout.setContentsMargins(1, 1, 1, 1)

        _glayout = qt_import.QGridLayout()

        self.groupBox.setLayout(_glayout)

        self.current_label = qt_import.QLabel("Machine current:")
        self.current_value_label = qt_import.QLabel()
        self.current_value_label.setAlignment(qt_import.Qt.AlignCenter)
        self.current_value_label.setStyleSheet(
            "font-size: 24px;font-weight: bold; color: #00f")

        # State text
        self.state_text_label = qt_import.QLabel("Machine status:")
        self.state_text_value_label = qt_import.QLabel()
        self.state_text_value_label.setAlignment(qt_import.Qt.AlignCenter)
        self.state_text_value_label.setStyleSheet("font-size: 18px;")

        # TopUp Remaining
        self.topup_remaining_label = qt_import.QLabel("TopUp Remaining:")
        self.topup_remaining_value_label = qt_import.QLabel()
        self.topup_remaining_value_label.setAlignment(qt_import.Qt.AlignCenter)
        self.topup_remaining_value_label.setStyleSheet("font-size: 18px;")

        # Layout --------------------------------------------------------------
        _glayout.addWidget(self.current_label, 0, 0)
        _glayout.addWidget(self.current_value_label, 0, 1)
        _glayout.addWidget(self.state_text_label, 1, 0)
        _glayout.addWidget(self.state_text_value_label, 1, 1)
        _glayout.addWidget(self.topup_remaining_label, 2, 0)
        _glayout.addWidget(self.topup_remaining_value_label, 2, 1)
        _glayout.setSpacing(1)
        _glayout.setContentsMargins(8, 8, 8, 8)

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

        # Other ---------------------------------------------------------------
        self.setToolTip("Main information about machine current, " +
                        "machine status and top-up remaining time.")
Esempio n. 2
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

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

        # Internal values -----------------------------------------------------
        self.motor_hwobj_list = []
        self.motor_widget_list = []
        self.motor_widget_labels = []
        self.predefined_positions_list = []
        self.positions = None

        # Properties ----------------------------------------------------------
        self.add_property("mnemonic", "string", "")
        self.add_property("labels", "string", "")
        self.add_property("moveButtonIcons", "string", "")
        self.add_property("alignment", "combo", ("vertical", "horizontal"),
                          "vertical")
        self.add_property("defaultSteps", "string", "")
        self.add_property("defaultDeltas", "string", "")
        self.add_property("defaultDecimals", "string", "")
        self.add_property("predefinedPositions", "string", "")
        self.add_property("showMoveButtons", "boolean", True)
        self.add_property("showSlider", "boolean", False)
        self.add_property("showStop", "boolean", True)
        self.add_property("showStep", "boolean", True)
        self.add_property("showEnableButtons", "boolean", False)
        self.add_property("inExpertMode", "boolean", False)

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

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

        # Graphic elements ----------------------------------------------------
        self.main_group_box = qt_import.QGroupBox(self)
        self.enable_motors_buttons = qt_import.QPushButton(
            "Enable", self.main_group_box)
        self.disable_motors_buttons = qt_import.QPushButton(
            "Disable", self.main_group_box)

        # Layout --------------------------------------------------------------
        if self["alignment"] == "horizontal":
            self.main_groupbox_hlayout = qt_import.QHBoxLayout(
                self.main_group_box)
        else:
            self.main_groupbox_hlayout = qt_import.QVBoxLayout(
                self.main_group_box)
        self.main_groupbox_hlayout.setSpacing(2)
        self.main_groupbox_hlayout.setContentsMargins(0, 0, 0, 0)

        self.main_hlayout = qt_import.QHBoxLayout(self)
        self.main_hlayout.addWidget(self.main_group_box)
        self.main_hlayout.setSpacing(2)
        self.main_hlayout.setContentsMargins(2, 2, 2, 2)

        # Size Policy ---------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.enable_motors_buttons.clicked.connect(self.enable_motors)
        self.disable_motors_buttons.clicked.connect(self.disable_motors)
Esempio n. 3
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

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

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

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

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

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

        # Layout --------------------------------------------------------------
        _main_groupbox_vlayout = qt_import.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 = qt_import.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, DETECTOR_STATES["uninitialized"]
        )
        colors.set_widget_color(
            self.temperature_label, STATES["unknown"]
        )
        colors.set_widget_color(
            self.humidity_label, STATES["unknown"]
        )
        colors.set_widget_color(self.frame_rate_label, STATES["OK"])

        self.status_label.setMinimumHeight(20)
        self.status_label.setAlignment(qt_import.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
        )
Esempio n. 4
0
    def select_proposal(self, selected_proposal):
        beamline_name = HWR.beamline.lims.beamline_name
        proposal = selected_proposal["Proposal"]
        # person = selected_proposal['Person']
        # laboratory = selected_proposal['Laboratory']
        sessions = selected_proposal["Session"]
        # Check if there are sessions in the proposal
        todays_session = None
        if sessions is None or len(sessions) == 0:
            pass
        else:
            # Check for today's session
            for session in sessions:
                beamline = session["beamlineName"]
                start_date = "%s 00:00:00" % session["startDate"].split()[0]
                end_date = "%s 23:59:59" % session["endDate"].split()[0]
                try:
                    start_struct = time.strptime(start_date, "%Y-%m-%d %H:%M:%S")
                except ValueError:
                    pass
                else:
                    try:
                        end_struct = time.strptime(end_date, "%Y-%m-%d %H:%M:%S")
                    except ValueError:
                        pass
                    else:
                        start_time = time.mktime(start_struct)
                        end_time = time.mktime(end_struct)
                        current_time = time.time()

                        # Check beamline name
                        if beamline == beamline_name:
                            # Check date
                            if current_time >= start_time and current_time <= end_time:
                                todays_session = session
                                break

        if todays_session is None:
            is_inhouse = HWR.beamline.session.is_inhouse(
                proposal["code"], proposal["number"]
            )
            if not is_inhouse:
                if BaseWidget.is_instance_role_client():
                    self.refuse_login(
                        None, "You don't have a session scheduled for today!"
                    )
                    return

            current_time = time.localtime()
            start_time = time.strftime("%Y-%m-%d 00:00:00", current_time)
            end_time = time.mktime(current_time) + 60 * 60 * 24
            tomorrow = time.localtime(end_time)
            end_time = time.strftime("%Y-%m-%d 07:59:59", tomorrow)

            # Create a session
            new_session_dict = {}
            new_session_dict["proposalId"] = selected_proposal["Proposal"]["proposalId"]
            new_session_dict["startDate"] = start_time
            new_session_dict["endDate"] = end_time
            new_session_dict["beamlineName"] = beamline_name
            new_session_dict["scheduled"] = 0
            new_session_dict["nbShifts"] = 3
            new_session_dict["comments"] = "Session created by MXCuBE"
            session_id = HWR.beamline.lims.create_session(new_session_dict)
            new_session_dict["sessionId"] = session_id

            todays_session = new_session_dict
            localcontact = None
        else:
            session_id = todays_session["sessionId"]
            logging.getLogger().debug(
                "ProposalBrick: getting local contact for %s" % session_id
            )
            localcontact = HWR.beamline.lims.get_session_local_contact(session_id)

        self.accept_login(selected_proposal["Proposal"], todays_session)
Esempio n. 5
0
 def property_changed(self, property_name, old_value, new_value):
     if property_name == "mnemonic":
         self.beam_align_hwobj = self.get_hardware_object(new_value)
     else:
         BaseWidget.property_changed(self, property_name, old_value,
                                     new_value)
Esempio n. 6
0
 def set_user_file_directory(self, user_file_directory):
     """Sets user file directory"""
     self.user_file_dir = user_file_directory
     BaseWidget.set_user_file_directory(user_file_directory)
Esempio n. 7
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

        # variables -----------------------------------------------------------

        self.list_of_operational_modes = []
        self.default_session = None

        self.multipos_file_xml_path = None
        self.bliss_session_list = None

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

        # Internal values -----------------------------------------------------
        self.table_created = False

        # Properties ----------------------------------------------------------
        self.add_property("mnemonic", "string", "/multiple-positions")

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

        self.define_signal("operation_modes_edited", ())
        self.define_signal("operation_modes_saved", ())
        self.define_signal("data_policy_changed", ())

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

        # Graphic elements ----------------------------------------------------
        self.main_groupbox = qt_import.QGroupBox("Beam Configuration", self)
        self.ui_widgets_manager = qt_import.load_ui_file(
            "esrf_id13_configuration_widget.ui")

        # Size policy --------------------------------
        self.ui_widgets_manager.configuration_table.setSizePolicy(
            qt_import.QSizePolicy.Minimum,
            qt_import.QSizePolicy.Minimum,
        )

        # Layout --------------------------------------------------------------
        _groupbox_vlayout = qt_import.QVBoxLayout(self)
        _groupbox_vlayout.addWidget(self.ui_widgets_manager)
        _groupbox_vlayout.setSpacing(0)
        _groupbox_vlayout.setContentsMargins(0, 0, 0, 0)
        self.main_groupbox.setLayout(_groupbox_vlayout)

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

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

        self.ui_widgets_manager.save_table_changes.clicked.connect(
            self.save_table_changes)

        self.ui_widgets_manager.cancel_table_changes.clicked.connect(
            self.cancel_table_changes)

        self.ui_widgets_manager.bliss_session_combo_box.currentIndexChanged.connect(
            self.display_data_policy)

        self.ui_widgets_manager.configuration_table.itemChanged.connect(
            self.configuration_table_item_changed)

        self.ui_widgets_manager.add_label_button.clicked.connect(
            self.add_op_mode_to_list)

        self.ui_widgets_manager.delete_label_button.clicked.connect(
            self.delete_op_mode_from_list)

        self.ui_widgets_manager.save_labels_button.clicked.connect(
            self.save_op_mode_list)

        self.ui_widgets_manager.label_list.itemSelectionChanged.connect(
            self.label_list_selection_changed)

        self.ui_widgets_manager.reload_data_policy_button.clicked.connect(
            self.reload_data_policy)
Esempio n. 8
0
    def __init__(self, *args):
        BaseWidget.__init__(self, *args)

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

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

        self.positions = None

        # Properties ----------------------------------------------------------
        self.add_property("label", "string", "")
        self.add_property("mnemonic", "string", "")
        self.add_property("icons", "string", "")
        self.add_property("showMoveButtons", "boolean", True)

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

        # Slots ---------------------------------------------------------------
        self.define_slot("setEnabled", ())

        # Graphic elements ----------------------------------------------------
        _main_gbox = qt_import.QGroupBox(self)
        self.label = qt_import.QLabel("motor:", _main_gbox)
        self.positions_combo = qt_import.QComboBox(self)
        self.position_label = qt_import.QLineEdit(self)
        self.position_label.setFixedWidth(60)
        self.previous_position_button = qt_import.QPushButton(_main_gbox)
        self.next_position_button = qt_import.QPushButton(_main_gbox)

        # Layout --------------------------------------------------------------
        _main_gbox_hlayout = qt_import.QHBoxLayout(_main_gbox)
        _main_gbox_hlayout.addWidget(self.label)
        _main_gbox_hlayout.addWidget(self.positions_combo)
        _main_gbox_hlayout.addWidget(self.position_label)
        _main_gbox_hlayout.addWidget(self.previous_position_button)
        _main_gbox_hlayout.addWidget(self.next_position_button)
        _main_gbox_hlayout.setSpacing(2)
        _main_gbox_hlayout.setContentsMargins(2, 2, 2, 2)

        _main_hlayout = qt_import.QHBoxLayout(self)
        _main_hlayout.addWidget(_main_gbox)
        _main_hlayout.setSpacing(0)
        _main_hlayout.setContentsMargins(0, 0, 0, 0)
        # Size Policy ---------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.positions_combo.activated.connect(self.position_selected)
        self.position_label.returnPressed.connect(self.position_edited)
        self.previous_position_button.clicked.connect(
            self.select_previous_position)
        self.next_position_button.clicked.connect(self.select_next_position)

        # Other ---------------------------------------------------------------
        self.positions_combo.setFixedHeight(27)
        self.positions_combo.setToolTip(
            "Moves the motor to a predefined position")
        self.previous_position_button.setIcon(icons.load_icon("Minus2"))
        self.previous_position_button.setFixedSize(27, 27)
        self.next_position_button.setIcon(icons.load_icon("Plus2"))
        self.next_position_button.setFixedSize(27, 27)
Esempio n. 9
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

        # Internal values -----------------------------------------------------
        self.__shape_map = {}
        self.__point_map = {}
        self.__line_map = {}
        self.__grid_map = {}
        self.__original_height = 300

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

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

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

        # Graphic elements ----------------------------------------------------
        self.main_groupbox = qt_import.QGroupBox("Graphics items", self)
        self.manager_widget = qt_import.load_ui_file(
            "graphics_manager_layout.ui")

        # Layout --------------------------------------------------------------
        _groupbox_vlayout = qt_import.QVBoxLayout(self)
        _groupbox_vlayout.addWidget(self.manager_widget)
        _groupbox_vlayout.setSpacing(0)
        _groupbox_vlayout.setContentsMargins(0, 0, 0, 0)
        self.main_groupbox.setLayout(_groupbox_vlayout)

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

        # Qt signal/slot connections ------------------------------------------
        self.main_groupbox.toggled.connect(self.main_groupbox_toggled)
        self.manager_widget.change_color_button.clicked.connect(
            self.change_color_clicked)
        self.manager_widget.display_all_button.clicked.connect(
            self.display_all_button_clicked)
        self.manager_widget.hide_all_button.clicked.connect(
            self.hide_all_button_clicked)
        self.manager_widget.clear_all_button.clicked.connect(
            self.clear_all_button_clicked)

        self.manager_widget.create_point_start_button.clicked.connect(
            self.create_point_start_button_clicked)
        self.manager_widget.create_point_accept_button.clicked.connect(
            self.create_point_accept_button_clicked)
        self.manager_widget.create_line_button.clicked.connect(
            self.create_line_button_clicked)
        self.manager_widget.draw_grid_button.clicked.connect(
            self.draw_grid_button_clicked)

        # self.manager_widget.shapes_treewidget.currentItemChanged.connect(\
        #     self.shape_treewiget_current_item_changed)
        self.manager_widget.shapes_treewidget.itemClicked.connect(
            self.shape_treewiget_item_clicked)
        self.manager_widget.shapes_treewidget.customContextMenuRequested.connect(
            self.show_shape_treewidget_popup)

        self.manager_widget.hor_spacing_ledit.textChanged.connect(
            self.grid_spacing_changed)
        self.manager_widget.ver_spacing_ledit.textChanged.connect(
            self.grid_spacing_changed)
        self.manager_widget.move_left_button.clicked.connect(
            self.grid_move_left_clicked)
        self.manager_widget.move_right_button.clicked.connect(
            self.grid_move_right_clicked)
        self.manager_widget.move_up_button.clicked.connect(
            self.grid_move_up_clicked)
        self.manager_widget.move_down_button.clicked.connect(
            self.grid_move_down_clicked)

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

        # Other ---------------------------------------------------------------
        # by default manager is closed
        self.main_groupbox.setCheckable(True)
        self.main_groupbox.setChecked(False)
        self.main_groupbox_toggled(False)
        self.main_groupbox.setToolTip("Click to open/close item manager")

        self.connect(HWR.beamline.sample_view, "shapeCreated",
                     self.shape_created)
        self.connect(HWR.beamline.sample_view, "shapeDeleted",
                     self.shape_deleted)
        self.connect(HWR.beamline.sample_view, "shapeSelected",
                     self.shape_selected)
        self.connect(HWR.beamline.sample_view, "centringInProgress",
                     self.centring_in_progress_changed)
Esempio n. 10
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

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

        # Internal values -----------------------------------------------------
        self.axis_camera = None
        self.sc_camera = None

        # Properties ----------------------------------------------------------
        self.add_property("hwobj_axis_camera", "string", "")
        self.add_property("hwobj_sc_camera", "string", "")

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

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

        # Graphic elements ----------------------------------------------------
        status_widget = qt_import.QWidget(self)
        status_label = qt_import.QLabel("Status: ", status_widget)
        self.status_ledit = qt_import.QLineEdit(status_widget)

        self.camera_live_cbx = qt_import.QCheckBox("Live view", self)
        self.camera_live_cbx.setChecked(False)

        self.progress_bar = qt_import.QProgressBar(self)
        self.progress_bar.setMinimum(0)

        camera_widget = qt_import.QWidget(self)

        self.axis_view = qt_import.QGraphicsView(camera_widget)
        axis_scene = qt_import.QGraphicsScene(self.axis_view)
        self.axis_view.setScene(axis_scene)
        self.axis_camera_pixmap_item = qt_import.QGraphicsPixmapItem()
        axis_scene.addItem(self.axis_camera_pixmap_item)

        self.sc_view = qt_import.QGraphicsView(camera_widget)
        sc_scene = qt_import.QGraphicsScene(self.sc_view)
        self.sc_view.setScene(sc_scene)
        self.sc_camera_pixmap_item = qt_import.QGraphicsPixmapItem()
        sc_scene.addItem(self.sc_camera_pixmap_item)

        # Layout --------------------------------------------------------------
        _status_widget_hlayout = qt_import.QHBoxLayout(status_widget)
        _status_widget_hlayout.addWidget(status_label)
        _status_widget_hlayout.addWidget(self.status_ledit)

        _camera_widget_hlayout = qt_import.QHBoxLayout(camera_widget)
        _camera_widget_hlayout.addWidget(self.axis_view)
        _camera_widget_hlayout.addWidget(self.sc_view)

        _main_vlayout = qt_import.QVBoxLayout(self)
        _main_vlayout.addWidget(status_widget)
        _main_vlayout.addWidget(self.camera_live_cbx)
        _main_vlayout.addWidget(camera_widget)
        _main_vlayout.addWidget(self.progress_bar)
        _main_vlayout.setSpacing(0)
        _main_vlayout.setContentsMargins(2, 2, 2, 2)

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

        # Qt signal/slot connections ------------------------------------------
        self.camera_live_cbx.stateChanged.connect(
            self.camera_live_state_changed)

        if HWR.beamline.sample_changer is not None:
            self.connect(
                HWR.beamline.sample_changer,
                SampleChanger.STATUS_CHANGED_EVENT,
                self.sample_changer_status_changed,
            )
            self.connect(HWR.beamline.sample_changer, "progressInit",
                         self.init_progress)
            self.connect(HWR.beamline.sample_changer, "progressStep",
                         self.step_progress)
            self.connect(HWR.beamline.sample_changer, "progressStop",
                         self.stop_progress)
Esempio n. 11
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)
        self.logger = logging.getLogger("HWR").info(
            "Creating GUI Alba Shutters State")

        # Hardware objects ----------------------------------------------------
        self.fast_shut_ho = None
        self.slow_shut_ho = None
        self.photon_shut_ho = None
        self.fe_ho = None

        self.default_led_size = 30

        # Properties ----------------------------------------------------------
        self.add_property("fast_shutter", "string", "")
        self.add_property("slow_shutter", "string", "")
        self.add_property("photon_shutter", "string", "")
        self.add_property("frontend", "string", "")
        self.add_property("led_size", "string", "")

        # Graphic elements ----------------------------------------------------
        self.shutter_box = qt_import.QGroupBox()
        self.shutter_box.setTitle("Beam on Sample")
        self.leds_layout = qt_import.QHBoxLayout(self.shutter_box)

        self.fast_led = QLed.QLed()
        self.fast_led.setUserName("Fast Shutter")

        self.slow_led = QLed.QLed()
        self.slow_led.setUserName("Slow Shutter")

        self.photon_led = QLed.QLed()
        self.photon_led.setUserName("Photon Shutter")

        self.fe_led = QLed.QLed()
        self.fe_led.setUserName("Front End")

        self.leds_layout.addWidget(self.fast_led)
        self.leds_layout.addWidget(self.slow_led)
        self.leds_layout.addWidget(self.photon_led)
        self.leds_layout.addWidget(self.fe_led)

        qt_import.QHBoxLayout(self)

        self.layout().addWidget(self.shutter_box)
        self.layout().setContentsMargins(0, 0, 0, 0)
        self.leds_layout.setContentsMargins(2, 2, 2, 2)

        self.set_led_size(self.default_led_size)
        # SizePolicies --------------------------------------------------------
        self.setSizePolicy(qt_import.QSizePolicy.Expanding,
                           qt_import.QSizePolicy.MinimumExpanding)

        # Other ---------------------------------------------------------------
        self.setToolTip("Beam on Sample. Shutters status")

        # self.slow_state_changed(True)
        # self.fast_state_changed(False)
        # self.frontend_state_changed(False)
        #
        #        self.fast_led.setShapeAndColor("circle","orange")
        #        self.fast_led.setMessage("in down position. X-Ray will go through")
        self.setEnabled(True)
Esempio n. 12
0
    def property_changed(self, property_name, old_value, new_value):
        self.fast_shut_ho = None
        self.slow_shut_ho = None
        self.photon_shut_ho = None
        self.fe_ho = None

        print("setting %s property to %s", property_name, new_value)

        if property_name == "fast_shutter":
            if self.fast_shut_ho is not None:
                self.disconnect(
                    self.fast_shut_ho,
                    qt_import.SIGNAL("stateChanged"),
                    self.fast_state_changed,
                )

            self.fast_shut_ho = self.get_hardware_object(new_value)

            if self.fast_shut_ho is not None:
                self.connect(
                    self.fast_shut_ho,
                    qt_import.SIGNAL("stateChanged"),
                    self.fast_state_changed,
                )

        elif property_name == "slow_shutter":
            if self.slow_shut_ho is not None:
                self.disconnect(
                    self.slow_shut_ho,
                    qt_import.SIGNAL("stateChanged"),
                    self.slow_state_changed,
                )

            self.slow_shut_ho = self.get_hardware_object(new_value)

            if self.slow_shut_ho is not None:
                self.connect(
                    self.slow_shut_ho,
                    qt_import.SIGNAL("stateChanged"),
                    self.slow_state_changed,
                )

        elif property_name == "photon_shutter":
            if self.photon_shut_ho is not None:
                self.disconnect(
                    self.photon_shut_ho,
                    qt_import.SIGNAL("stateChanged"),
                    self.photon_state_changed,
                )

            self.photon_shut_ho = self.get_hardware_object(new_value)

            if self.photon_shut_ho is not None:
                self.connect(
                    self.photon_shut_ho,
                    qt_import.SIGNAL("stateChanged"),
                    self.photon_state_changed,
                )

        elif property_name == "frontend":
            if self.fe_ho is not None:
                self.disconnect(
                    self.fe_ho,
                    qt_import.SIGNAL("stateChanged"),
                    self.frontend_state_changed,
                )

            self.fe_ho = self.get_hardware_object(new_value)

            if self.fe_ho is not None:
                self.connect(
                    self.fe_ho,
                    qt_import.SIGNAL("stateChanged"),
                    self.frontend_state_changed,
                )

        elif property_name == "led_size":
            if new_value != "":
                self.set_led_size(int(new_value))
        else:
            BaseWidget.property_changed(self, property_name, old_value,
                                        new_value)
Esempio n. 13
0
    def __init__(self, *args):
        BaseWidget.__init__(self, *args)

        # Internal values -----------------------------------------------------
        self.inside_data_collection = None
        self.prefix = "snapshot"
        self.file_index = 1

        # Properties ----------------------------------------------------------
        self.add_property("enableAutoFocus", "boolean", True)
        self.add_property("enableRefreshCamera", "boolean", False)
        self.add_property("enableVisualAlign", "boolean", True)
        self.add_property("enableAutoCenter", "boolean", True)
        self.add_property("enableRealignBeam", "boolean", False)

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

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

        # Graphic elements ----------------------------------------------------
        self.centre_button = DuoStateButton(self, "Centre")
        self.centre_button.set_icons("VCRPlay2", "Delete")
        self.accept_button = MonoStateButton(self, "Save", "ThumbUp")
        self.standard_color = self.accept_button.palette().color(
            qt_import.QPalette.Window)
        self.reject_button = MonoStateButton(self, "Reject", "ThumbDown")
        self.reject_button.hide()
        self.create_line_button = MonoStateButton(self, "Line", "Line")
        self.draw_grid_button = MonoStateButton(self, "Grid", "Grid")
        self.auto_focus_button = MonoStateButton(self, "Focus", "Eyeball")
        self.snapshot_button = MonoStateButton(self, "Snapshot", "Camera")
        self.refresh_camera_button = MonoStateButton(self, "Refresh",
                                                     "Refresh")
        self.visual_align_button = MonoStateButton(self, "Align", "Align")
        self.select_all_button = MonoStateButton(self, "Select all", "Check")
        self.clear_all_button = MonoStateButton(self, "Clear all", "Delete")
        self.auto_center_button = MonoStateButton(self, "Auto", "VCRPlay2")
        self.auto_center_button.setText("Auto")
        self.realign_button = MonoStateButton(self, "Realign beam",
                                              "QuickRealign")

        # Layout --------------------------------------------------------------
        _main_vlayout = qt_import.QVBoxLayout(self)
        _main_vlayout.addWidget(self.centre_button)
        _main_vlayout.addWidget(self.accept_button)
        _main_vlayout.addWidget(self.reject_button)
        _main_vlayout.addWidget(self.create_line_button)
        _main_vlayout.addWidget(self.draw_grid_button)
        _main_vlayout.addWidget(self.auto_focus_button)
        _main_vlayout.addWidget(self.snapshot_button)
        _main_vlayout.addWidget(self.refresh_camera_button)
        _main_vlayout.addWidget(self.visual_align_button)
        _main_vlayout.addWidget(self.select_all_button)
        _main_vlayout.addWidget(self.clear_all_button)
        _main_vlayout.addWidget(self.auto_center_button)
        _main_vlayout.addWidget(self.realign_button)
        _main_vlayout.addStretch(0)
        _main_vlayout.setSpacing(0)
        _main_vlayout.setContentsMargins(0, 0, 0, 0)

        # Qt signal/slot connections ------------------------------------------
        self.centre_button.commandExecuteSignal.connect(
            self.centre_button_clicked)
        self.accept_button.clicked.connect(self.accept_clicked)
        self.reject_button.clicked.connect(self.reject_clicked)
        self.create_line_button.clicked.connect(create_line_clicked)
        self.draw_grid_button.clicked.connect(draw_grid_clicked)
        self.auto_focus_button.clicked.connect(auto_focus_clicked)
        self.snapshot_button.clicked.connect(self.save_snapshot_clicked)
        self.refresh_camera_button.clicked.connect(refresh_camera_clicked)
        self.visual_align_button.clicked.connect(visual_align_clicked)
        self.select_all_button.clicked.connect(select_all_clicked)
        self.clear_all_button.clicked.connect(clear_all_clicked)
        self.auto_center_button.clicked.connect(auto_center_clicked)

        # Other ---------------------------------------------------------------
        self.centre_button.setToolTip("3 click centring")
        self.accept_button.setToolTip(
            "Accept 3 click centring or "
            "create a point\nbased on current position")
        self.reject_button.setToolTip("Reject centring")
        self.create_line_button.setToolTip(
            "Create helical line between two points")
        self.draw_grid_button.setToolTip("Create grid with drag and drop")
        self.select_all_button.setToolTip("Select all centring points")
        self.clear_all_button.setToolTip("Clear all items")
        # self.instanceSynchronize("")

        self.connect(HWR.beamline.sample_view, "centringStarted",
                     self.centring_started)
        self.connect(HWR.beamline.sample_view, "centringFailed",
                     self.centring_failed)
        self.connect(HWR.beamline.sample_view, "centringSuccessful",
                     self.centring_successful)
        self.connect(
            HWR.beamline.sample_view,
            "diffractometerPhaseChanged",
            self.diffractometer_phase_changed,
        )
Esempio n. 14
0
    def property_changed(self, property_name, old_value, new_value):
        if property_name == "mnemonic":
            hwobj_names_list = new_value.split()

            default_delta_list = self["defaultDeltas"].split()
            default_decimal_list = self["defaultDecimals"].split()
            default_step_list = self["defaultSteps"].split()

            for index, hwobj_name in enumerate(hwobj_names_list):
                temp_motor_hwobj = self.get_hardware_object(hwobj_name)
                if temp_motor_hwobj is not None:
                    temp_motor_widget = MotorSpinboxBrick(self)
                    temp_motor_widget.set_motor(temp_motor_hwobj, hwobj_name)
                    temp_motor_widget.move_left_button.setVisible(
                        self["showMoveButtons"])
                    temp_motor_widget.move_right_button.setVisible(
                        self["showMoveButtons"])
                    temp_motor_widget.position_slider.setVisible(
                        self["showSlider"])
                    temp_motor_widget.step_button.setVisible(self["showStep"])
                    temp_motor_widget.stop_button.setVisible(self["showStop"])

                    try:
                        temp_motor_widget.set_line_step(
                            default_step_list[index])
                        temp_motor_widget["defaultStep"] = default_step_list[
                            index]
                    except BaseException:
                        temp_motor_widget.set_line_step(0.001)
                        temp_motor_widget["defaultStep"] = 0.001

                    try:
                        temp_motor_widget["delta"] = default_delta_list[index]
                    except BaseException:
                        temp_motor_widget["delta"] = 0.001
                    try:
                        temp_motor_widget.set_decimals(
                            float(default_decimal_list[index]))
                    except BaseException:
                        pass

                    temp_motor_widget.step_changed(None)
                    self.main_groupbox_hlayout.addWidget(temp_motor_widget)

                    self.motor_hwobj_list.append(temp_motor_hwobj)
                    self.motor_widget_list.append(temp_motor_widget)

                    temp_motor_hwobj.force_emit_signals()
                    temp_motor_widget.update_gui()

            self.enable_motors_buttons.setVisible(self["showEnableButtons"])
            self.disable_motors_buttons.setVisible(self["showEnableButtons"])
            if self["showEnableButtons"]:
                self.main_groupbox_hlayout.addWidget(
                    self.enable_motors_buttons)
                self.main_groupbox_hlayout.addWidget(
                    self.disable_motors_buttons)
            if len(self.motor_widget_labels):
                for index, label in enumerate(self.motor_widget_labels):
                    self.motor_widget_list[index].setLabel(label)
        elif property_name == "moveButtonIcons":
            icon_list = new_value.split()
            for index in range(len(icon_list) - 1):
                if index % 2 == 0:
                    self.motor_widget_list[index / 2].move_left_button.setIcon(
                        icons.load_icon(icon_list[index]))
                    self.motor_widget_list[index /
                                           2].move_right_button.setIcon(
                                               icons.load_icon(
                                                   icon_list[index + 1]))
        elif property_name == "labels":
            self.motor_widget_labels = new_value.split()
            if len(self.motor_widget_list):
                for index, label in enumerate(self.motor_widget_labels):
                    self.motor_widget_list[index].setLabel(label)
        elif property_name == "predefinedPositions":
            self.predefined_positions_list = new_value.split()
            for predefined_position in self.predefined_positions_list:
                temp_position_button = qt_import.QPushButton(
                    predefined_position, self.main_group_box)
                self.main_groupbox_hlayout.addWidget(temp_position_button)
                temp_position_button.clicked.connect(
                    lambda: self.predefined_position_clicked(
                        predefined_position))
        else:
            BaseWidget.property_changed(self, property_name, old_value,
                                        new_value)
Esempio n. 15
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

        # Internal variables ------------------------------------------------
        self.sample = queue_model_objects.Sample()
        self.crystal = self.sample.crystals[0]
        self.sample_mib = DataModelInputBinder(self.sample)
        self.crystal_mib = DataModelInputBinder(self.crystal)

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

        # Slots --------------------------------------------------------------
        self.define_slot("populate_sample_details", ({}))

        # Graphic elements ----------------------------------------------------
        _info_widget = qt_import.QWidget(self)
        self.crystal_widget = qt_import.load_ui_file("crystal_widget_layout.ui")
        self.sample_info_widget = qt_import.load_ui_file("sample_info_widget_layout.ui")
        # self.ispyb_sample_info_widget = ISPyBSampleInfoWidget(self)

        # Layout --------------------------------------------------------------
        _info_widget_hlayout = qt_import.QHBoxLayout(_info_widget)
        _info_widget_hlayout.addWidget(self.sample_info_widget)
        _info_widget_hlayout.addWidget(self.crystal_widget)
        _info_widget_hlayout.addStretch(0)
        _info_widget_hlayout.setSpacing(0)
        _info_widget_hlayout.setContentsMargins(2, 2, 2, 2)

        _main_hlayout = qt_import.QVBoxLayout(self)
        _main_hlayout.addWidget(_info_widget)
        # _main_hlayout.addWidget(self.ispyb_sample_info_widget)
        _main_hlayout.addStretch(0)
        _main_hlayout.setSpacing(0)
        _main_hlayout.setContentsMargins(2, 2, 2, 2)

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

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

        # Other ---------------------------------------------------------------
        self.crystal_mib.bind_value_update(
            "space_group", self.crystal_widget.space_group_value_label, str, None
        )

        self.crystal_mib.bind_value_update(
            "protein_acronym",
            self.crystal_widget.protein_acronym_value_label,
            str,
            None,
        )

        self.crystal_mib.bind_value_update(
            "cell_a", self.crystal_widget.a_value_label, str, None
        )

        self.crystal_mib.bind_value_update(
            "cell_alpha", self.crystal_widget.alpha_value_label, str, None
        )

        self.crystal_mib.bind_value_update(
            "cell_b", self.crystal_widget.b_value_label, str, None
        )

        self.crystal_mib.bind_value_update(
            "cell_beta", self.crystal_widget.beta_value_label, str, None
        )

        self.crystal_mib.bind_value_update(
            "cell_c", self.crystal_widget.c_value_label, str, None
        )

        self.crystal_mib.bind_value_update(
            "cell_gamma", self.crystal_widget.gamma_value_label, str, None
        )

        self.sample_mib.bind_value_update(
            "name", self.sample_info_widget.name_value_label, str, None
        )

        self.sample_mib.bind_value_update(
            "code", self.sample_info_widget.data_matrix_value_label, str, None
        )

        self.sample_mib.bind_value_update(
            "holder_length",
            self.sample_info_widget.holder_length_value_label,
            str,
            None,
        )

        self.sample_mib.bind_value_update(
            "lims_sample_location",
            self.sample_info_widget.sample_location_value_label,
            str,
            None,
        )

        self.sample_mib.bind_value_update(
            "lims_container_location",
            self.sample_info_widget.basket_location_value_label,
            str,
            None,
        )
Esempio n. 16
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()

                self.update_zoom()

                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,
                    DigitalZoomBrick.STATE_COLORS[0],
                    qt_import.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)
Esempio n. 17
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

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

        # Internal values -----------------------------------------------------
        self.num_clicked_centring_pos = 0
        
        # Properties ----------------------------------------------------------

        # Signals ------------------------------------------------------------
        self.define_signal("centring_parameters_changed", ())

        # Slots ---------------------------------------------------------------
        
        # Graphic elements ----------------------------------------------------
        self.main_groupbox = qt_import.QGroupBox("Sample centering", self)
        self.ui_widgets_manager = qt_import.load_ui_file("esrf_sample_centering.ui")

        # Size policy --------------------------------
        self.ui_widgets_manager.aligment_table.setSizePolicy(
            qt_import.QSizePolicy.Minimum,
            qt_import.QSizePolicy.Minimum,
        )

        # Layout --------------------------------------------------------------
        _groupbox_vlayout = qt_import.QVBoxLayout()
        _groupbox_vlayout.addWidget(self.ui_widgets_manager)
        self.main_groupbox.setLayout(_groupbox_vlayout)

        # MatPlotWidget --------------------------------------------------------------
         # a figure instance to plot on
        self.figure = plt.figure()
        # this is the Canvas Widget that displays the `figure`
        # it takes the `figure` instance as a parameter to __init__
        self.canvas = FigureCanvas(self.figure)

        # this is the Navigation widget
        # it takes the Canvas widget and a parent
        self.toolbar = NavigationToolbar(self.canvas, self)
        _matplotlib_widget_layout = qt_import.QVBoxLayout()
        _matplotlib_widget_layout.addWidget(self.toolbar)
        _matplotlib_widget_layout.addWidget(self.canvas)
        
        # Layout --------------------------------------------------------------
        _main_vlayout = qt_import.QHBoxLayout()
        _main_vlayout.addWidget(self.main_groupbox)
        _main_vlayout.addLayout(_matplotlib_widget_layout)
        self.setLayout(_main_vlayout)

        # Qt signal/slot connections ------------------------------------------
       
        self.ui_widgets_manager.show_center_checkbox.stateChanged.connect(
            self.show_center
        )

        self.ui_widgets_manager.show_help_line_checkbox.stateChanged.connect(
            self.show_help_lines
        )
        
        self.ui_widgets_manager.number_points_spinbox.valueChanged.connect(
            self.change_point_number
        )

        self.ui_widgets_manager.delta_phi_textbox.editingFinished.connect(
            self.delta_phi_changed
        )

        self.ui_widgets_manager.start_alignment_button.clicked.connect(
            self.start_centring
        )

        self.ui_widgets_manager.cancel_alignment_button.clicked.connect(
            self.cancel_centring
        )

        # TODO : add show center and show help line functionalities
        self.ui_widgets_manager.show_center_checkbox.hide()
        self.ui_widgets_manager.show_help_line_checkbox.hide()
        
        # Other ---------------------------------------------------------------

        self.plot_data_X = []
        self.plot_data_Y = []
        self.connect(HWR.beamline.sample_view, "centringStarted", self.centring_started)
        self.connect(HWR.beamline.sample_view, "centringFailed", self.centring_failed)
        self.connect(
            HWR.beamline.sample_view, "centringSuccessful", self.centring_successful
        )
        self.connect(HWR.beamline.diffractometer, "centring_image_clicked", self.image_clicked)
        self.connect(HWR.beamline.diffractometer, "centring_calculation_ended", self.show_centring_paremeters)

        self.change_point_number(self.points_for_aligment)

        # init delta_phi var value
        self.delta_phi_changed()

        # match default values in .ui file
        self.points_for_aligment = self.ui_widgets_manager.number_points_spinbox.value()
        self.delta_phi = float(self.ui_widgets_manager.delta_phi_textbox.text())
Esempio n. 18
0
    def __init__(self, *args):
        BaseWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------
        self.beamline_test_hwobj = None
        self.unittest_hwobj = None

        # Internal variables --------------------------------------------------
        self.available_tests = None
        self.com_device_list = None

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

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

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

        # Graphic elements ----------------------------------------------------
        self.beamline_test_widget = qt_import.load_ui_file(
            "beamline_test_widget_layout.ui"
        )

        self.test_toolbox = self.beamline_test_widget.test_toolbox
        self.test_queue_page = self.beamline_test_widget.queue_toolbox_page
        self.test_com_page = self.beamline_test_widget.com_toolbox_page
        self.test_focus_page = self.beamline_test_widget.focus_toolbox_page
        self.test_ppu_page = self.beamline_test_widget.ppu_toolbox_page

        self.com_device_table = self.beamline_test_widget.comm_device_table
        # self.current_test_listwidget = self.beamline_test_widget.current_test_listbox
        self.available_tests_listwidget = (
            self.beamline_test_widget.available_tests_listwidget
        )

        _web_view_widget = qt_import.QWidget(self)
        _load_last_test_button = qt_import.QPushButton(
            "View last results", _web_view_widget
        )
        self.test_result_browser = WebViewWidget(_web_view_widget)

        # Layout --------------------------------------------------------------
        _web_view_widget_vlayout = qt_import.QVBoxLayout(_web_view_widget)
        _web_view_widget_vlayout.addWidget(_load_last_test_button)
        _web_view_widget_vlayout.addWidget(self.test_result_browser)
        _web_view_widget_vlayout.setSpacing(2)
        _web_view_widget_vlayout.setContentsMargins(0, 0, 0, 0)

        _main_vlayout = qt_import.QHBoxLayout(self)
        _main_vlayout.addWidget(self.beamline_test_widget)
        _main_vlayout.addWidget(_web_view_widget)
        _main_vlayout.setSpacing(2)
        _main_vlayout.setContentsMargins(2, 2, 2, 2)

        # Qt signal/slot connections ------------------------------------------
        self.beamline_test_widget.execute_all_button.clicked.connect(
            self.execute_all_tests_clicked
        )
        self.beamline_test_widget.test_button.clicked.connect(self.execute_test_clicked)
        self.beamline_test_widget.focus_modes_combo.activated.connect(
            self.set_focus_mode_pressed
        )
        self.available_tests_listwidget.itemDoubleClicked.connect(
            self.available_tests_double_clicked
        )

        _load_last_test_button.clicked.connect(self.load_latest_test_results)
        self.beamline_test_widget.ppu_restart_button.clicked.connect(self.restart_ppu)

        # Other ---------------------------------------------------------------
        # self.beamline_test_widget.setFixedWidth(600)
        self.test_result_browser.setSizePolicy(
            qt_import.QSizePolicy.Expanding, qt_import.QSizePolicy.Expanding
        )
        _load_last_test_button.setFixedWidth(200)

        self.test_toolbox.setCurrentWidget(self.test_queue_page)
        self.beamline_test_widget.setFixedWidth(700)
        self.test_result_browser.navigation_bar.setHidden(True)
Esempio n. 19
0
    def __init__(self, *args):
        BaseWidget.__init__(self, *args)

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

        # Internal values -----------------------------------------------------
        self.current_chip_config = None
        self.chip_file_dir = ""
        self.chip_filenames_list = []
        self.shortlist_dir = ""

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

        # Properties to initialize hardware objects --------------------------
        self.add_property("hwobj_ssx_control", "string", "")

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

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

        # Graphic elements ----------------------------------------------------
        self.ssx_widget_layout = qt_import.load_ui_file(
            "ssx_control_widget_layout.ui")

        # Layout --------------------------------------------------------------
        _main_layout = qt_import.QVBoxLayout(self)
        _main_layout.addWidget(self.ssx_widget_layout)

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

        # Qt signal/slot connections ------------------------------------------
        self.ssx_widget_layout.start_button.clicked.connect(
            self.start_experiment)
        self.ssx_widget_layout.chip_file_dir_browse_button.clicked.connect(
            self.get_chip_file_directory)
        self.ssx_widget_layout.shortlist_dir_browse_button.clicked.connect(
            self.get_shortlist_directory)
        self.ssx_widget_layout.save_chip_data_button.clicked.connect(
            self.save_chip_data)
        self.ssx_widget_layout.create_shortlist_button.clicked.connect(
            self.create_short_list)
        self.ssx_widget_layout.enable_all_button.clicked.connect(
            self.enable_all)
        self.ssx_widget_layout.disable_all_button.clicked.connect(
            self.disable_all)
        self.ssx_widget_layout.color_table.itemSelectionChanged.connect(
            self.change_cell_color)
        self.ssx_widget_layout.quarter_density_checkbox.stateChanged.connect(
            self.quarter_density_enabled)
        self.ssx_widget_layout.quarter_density_checkbox.setEnabled(False)
        self.ssx_widget_layout.meandering_checkbox.stateChanged.connect(
            self.meandering_enabled)

        # Other ---------------------------------------------------------------
        self.ssx_widget_layout.crystal_h_pitch_spinbox.valueChanged.connect(
            self.crystal_h_pitch_changed)
        self.ssx_widget_layout.crystal_v_pitch_spinbox.valueChanged.connect(
            self.crystal_v_pitch_changed)
        self.ssx_widget_layout.comp_h_pitch_spinbox.valueChanged.connect(
            self.comp_h_pitch_changed)
        self.ssx_widget_layout.comp_v_pitch_spinbox.valueChanged.connect(
            self.comp_v_pitch_changed)
        self.ssx_widget_layout.num_crystal_h_spinbox.valueChanged.connect(
            self.num_crystal_h_changed)
        self.ssx_widget_layout.num_crystal_v_spinbox.valueChanged.connect(
            self.num_crystal_v_changed)
        self.ssx_widget_layout.num_comp_h_spinbox.valueChanged.connect(
            self.num_comp_h_changed)
        self.ssx_widget_layout.num_comp_v_spinbox.valueChanged.connect(
            self.num_copm_v_changed)

        self.ssx_widget_layout.meandering_checkbox.setEnabled(False)

        # connect exposures per feature
        self.ssx_widget_layout.exp_per_feature_spinbox.valueChanged[
            unicode].connect(self.set_exposures_per_feature)
        # show names and one column at exposures per feature
        self.ssx_widget_layout.dg_channels_table.setRowCount(4)
        self.ssx_widget_layout.dg_channels_table.setColumnCount(1)
        # headers names
        self.ssx_widget_layout.dg_channels_table.setVerticalHeaderLabels(
            qt_import.QString("Detector;Excitation;Aux1;Aux2").split(";"))
        # set first column of checkboxes
        dg_channels_list = []

        for row in range(0, 4):
            checkbox_item = qt_import.QTableWidgetItem()
            checkbox_item.setFlags(qt_import.Qt.ItemIsUserCheckable
                                   | qt_import.Qt.ItemIsEnabled)
            checkbox_item.setCheckState(qt_import.Qt.Unchecked)
            dg_channels_list.append(checkbox_item)
            self.ssx_widget_layout.dg_channels_table.setItem(
                row, 0, checkbox_item)

        # set a color table with 3 by 3 cells
        self.ssx_widget_layout.color_table.setRowCount(3)
        self.ssx_widget_layout.color_table.setColumnCount(3)
        # set min size of cells
        self.ssx_widget_layout.color_table.horizontalHeader(
        ).setDefaultSectionSize(25)
        self.ssx_widget_layout.color_table.verticalHeader(
        ).setDefaultSectionSize(25)
        # table is non editable
        self.ssx_widget_layout.color_table.setEditTriggers(
            qt_import.QAbstractItemView.NoEditTriggers)
        # fill the table with empty items
        for row in range(0, 3):
            for column in range(0, 3):
                self.ssx_widget_layout.color_table.setItem(
                    row, column, qt_import.QTableWidgetItem())
                self.ssx_widget_layout.color_table.item(
                    row, column).setBackground(colors.GREEN)

        # connect scan rate
        self.ssx_widget_layout.scan_rate_ledit.textEdited.connect(
            self.scan_rate_text_changed)
Esempio n. 20
0
 def property_changed(self, property_name, old_value, new_value):
     BaseWidget.property_changed(self, property_name, old_value, new_value)
Esempio n. 21
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

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

        # Internal values -----------------------------------------------------
        self.crl_value = []

        # Properties ----------------------------------------------------------
        self.add_property("lenseCount", "integer", 6)
        self.add_property("mnemonic", "string", "")
        self.add_property("formatString", "formatString", "#.#")
        self.add_property("caption", "string", "")
        self.add_property(
            "style", "combo", ("table", "number"), "table"
        )

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

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

        # Graphic elements ----------------------------------------------------
        self.main_gbox = qt_import.QGroupBox("CRL", self)
        self.mode_combo = qt_import.QComboBox(self.main_gbox)
        self.set_according_to_energy_button = qt_import.QPushButton(
            "Set", self.main_gbox)
        self.set_out_button = qt_import.QPushButton("Out", self.main_gbox)
        # self.align_beam_button = qt_import.QtGui.QPushButton("Align", self.main_gbox)

        self.crl_widget = qt_import.QWidget(self.main_gbox)
        self.crl_value_table = qt_import.QTableWidget(self.crl_widget)
        self.crl_lense_spinbox = qt_import.QSpinBox(self.crl_widget)
        self.crl_lense_in_button = qt_import.QPushButton("In", self.crl_widget)
        self.crl_lense_out_button = qt_import.QPushButton("Out", self.crl_widget)

        self.move_up_button = qt_import.QPushButton("", self.main_gbox)
        self.move_down_button = qt_import.QPushButton("", self.main_gbox)

        # Layout --------------------------------------------------------------
        _crl_widget_hlayout = qt_import.QHBoxLayout(self.crl_widget)
        _crl_widget_hlayout.addWidget(self.crl_value_table)
        _crl_widget_hlayout.addWidget(self.crl_lense_spinbox)
        _crl_widget_hlayout.addWidget(self.crl_lense_in_button)
        _crl_widget_hlayout.addWidget(self.crl_lense_out_button)
        _crl_widget_hlayout.setSpacing(2)
        _crl_widget_hlayout.setContentsMargins(0, 0, 0, 0)

        _main_gbox_gridlayout = qt_import.QGridLayout(self.main_gbox)
        _main_gbox_gridlayout.addWidget(self.mode_combo, 0, 0)
        _main_gbox_gridlayout.addWidget(self.set_according_to_energy_button, 0, 1)
        _main_gbox_gridlayout.addWidget(self.set_out_button, 1, 1)
        _main_gbox_gridlayout.addWidget(self.crl_widget, 1, 0)
        # _main_gbox_gridlayout.addWidget(self.align_beam_button, 1, 1)
        _main_gbox_gridlayout.addWidget(self.move_up_button, 0, 2)
        _main_gbox_gridlayout.addWidget(self.move_down_button, 1, 2)
        _main_gbox_gridlayout.setSpacing(2)
        _main_gbox_gridlayout.setContentsMargins(2, 2, 2, 2)

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

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

        # Qt signal/slot connections ------------------------------------------
        self.mode_combo.activated.connect(self.set_crl_mode)
        self.crl_value_table.itemDoubleClicked.connect(
            self.crl_table_item_doubleclicked
        )
        self.set_according_to_energy_button.clicked.connect(
            self.set_according_to_energy
        )
        self.set_out_button.clicked.connect(self.set_out_clicked)
        self.move_up_button.clicked.connect(self.move_up_clicked)
        self.move_down_button.clicked.connect(self.move_down_clicked)

        # Other ---------------------------------------------------------------
        self.mode_combo.setCurrentIndex(1)
        self.crl_value_table.setRowCount(1)
        self.crl_value_table.verticalHeader().hide()
        self.crl_value_table.horizontalHeader().hide()
        self.crl_value_table.setRowHeight(0, 20)
        self.crl_value_table.setFixedHeight(24)
        self.crl_value_table.setShowGrid(True)

        # self.set_according_to_energy_button.setIcon(icons.load_icon("Up2"))
        # self.set_out_button.setIcon(icons.load_icon("Up2"))
        self.move_up_button.setIcon(icons.load_icon("Up2"))
        self.move_up_button.setFixedWidth(25)
        self.move_down_button.setIcon(icons.load_icon("Down2"))
        self.move_down_button.setFixedWidth(25)

        self.set_according_to_energy_button.setFixedWidth(30)
        self.set_out_button.setFixedWidth(30)
        self.crl_lense_in_button.setFixedWidth(30)
        self.crl_lense_out_button.setFixedWidth(30)
Esempio n. 22
0
    def execute(self, config):
        """Start in execution mode"""
        self.splash_screen.set_message("Executing configuration...")
        self.splash_screen.set_progress_value(90)
        self.display()

        main_window = None

        if len(self.windows) > 0:
            main_window = self.windows[0]
            main_window.configuration = config
            qt_import.QApplication.setActiveWindow(main_window)
            if self.no_border:
                main_window.move(0, 0)
                width = qt_import.QApplication.desktop().width()
                height = qt_import.QApplication.desktop().height()
                main_window.resize(qt_import.QSize(width, height))

            # make connections
            widgets_dict = dict([(
                isinstance(w.objectName, collections.Callable)
                and str(w.objectName()) or None,
                w,
            ) for w in qt_import.QApplication.allWidgets()])

            def make_connections(items_list):
                """Creates connections"""

                for item in items_list:
                    try:
                        sender = widgets_dict[item["name"]]
                    except KeyError:
                        logging.getLogger().error(
                            "Could not find receiver widget %s" % item["name"])
                    else:
                        for connection in item["connections"]:
                            _receiver = (connection["receiver"]
                                         or connection["receiverWindow"])
                            try:
                                receiver = widgets_dict[_receiver]
                            except KeyError:
                                logging.getLogger().error(
                                    "Could not find " + "receiver widget %s",
                                    _receiver)
                            else:
                                try:
                                    slot = getattr(receiver,
                                                   connection["slot"])
                                    # etattr(sender, connection["signal"]).connect(slot)
                                except AttributeError:
                                    logging.getLogger().error(
                                        "No slot '%s' " % connection["slot"] +
                                        "in receiver %s" % _receiver)
                                else:
                                    if not isinstance(sender, NullBrick):
                                        getattr(
                                            sender,
                                            connection["signal"]).connect(slot)
                                    # sender.connect(sender,
                                    #    QtCore.SIGNAL(connection["signal"]),
                                    #    slot)
                    make_connections(item["children"])

            self.splash_screen.set_progress_value(95)
            self.splash_screen.set_message("Connecting bricks...")
            make_connections(config.windows_list)

            # set run mode for every brick
            self.splash_screen.set_progress_value(100)
            self.splash_screen.set_message("Setting run mode...")
            BaseWidget.set_run_mode(True)

            if self.show_maximized:
                main_window.showMaximized()
            else:
                main_window.show()

            for window in self.windows:
                if window._show:
                    window.show()

        if BaseWidget._menubar:
            BaseWidget._menubar.set_exp_mode(False)

        HWR.beamline.force_emit_signals()

        return main_window
Esempio n. 23
0
    def __init__(self, *args):
        BaseWidget.__init__(self, *args)

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

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

        # Properties ----------------------------------------------------------
        self.add_property("label", "string", "")
        self.add_property("showStop", "boolean", True)
        self.add_property("defaultStep", "string", "10.0")

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

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

        # Graphic elements-----------------------------------------------------
        _main_gbox = qt_import.QGroupBox(self)

        self.kappa_dspinbox = qt_import.QDoubleSpinBox(_main_gbox)
        self.kappa_dspinbox.setRange(-360, 360)
        self.kappaphi_dspinbox = qt_import.QDoubleSpinBox(_main_gbox)
        self.kappaphi_dspinbox.setRange(-360, 360)
        self.step_cbox = qt_import.QComboBox(_main_gbox)
        self.step_button_icon = icons.load_icon("TileCascade2")
        self.close_button = qt_import.QPushButton(_main_gbox)
        self.stop_button = qt_import.QPushButton(_main_gbox)

        # Layout --------------------------------------------------------------
        _main_gbox_hlayout = qt_import.QHBoxLayout(_main_gbox)
        _main_gbox_hlayout.addWidget(qt_import.QLabel("Kappa:", _main_gbox))
        _main_gbox_hlayout.addWidget(self.kappa_dspinbox)
        _main_gbox_hlayout.addWidget(qt_import.QLabel("Phi:", _main_gbox))
        _main_gbox_hlayout.addWidget(self.kappaphi_dspinbox)
        _main_gbox_hlayout.addWidget(self.step_cbox)
        _main_gbox_hlayout.addWidget(self.close_button)
        _main_gbox_hlayout.addWidget(self.stop_button)
        _main_gbox_hlayout.setSpacing(2)
        _main_gbox_hlayout.setContentsMargins(2, 2, 2, 2)

        _main_hlayout = qt_import.QHBoxLayout(self)
        _main_hlayout.addWidget(_main_gbox)
        _main_hlayout.setSpacing(0)
        _main_hlayout.setContentsMargins(0, 0, 0, 0)

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

        # Qt signal/slot connections ------------------------------------------
        kappa_dspinbox_event = SpinBoxEvent(self.kappa_dspinbox)
        kappaphi_dspinbox_event = SpinBoxEvent(self.kappaphi_dspinbox)
        self.kappa_dspinbox.installEventFilter(kappa_dspinbox_event)
        self.kappaphi_dspinbox.installEventFilter(kappaphi_dspinbox_event)
        kappa_dspinbox_event.returnPressedSignal.connect(self.change_position)
        kappaphi_dspinbox_event.returnPressedSignal.connect(self.change_position)
        self.kappa_dspinbox.lineEdit().textEdited.connect(self.kappa_value_edited)
        self.kappaphi_dspinbox.lineEdit().textEdited.connect(self.kappaphi_value_edited)

        self.step_cbox.activated.connect(self.go_to_step)
        self.step_cbox.activated.connect(self.step_changed)
        self.step_cbox.editTextChanged.connect(self.step_edited)

        self.close_button.clicked.connect(self.close_clicked)
        self.stop_button.clicked.connect(self.stop_clicked)

        # self.stop_button.setSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Minimum)
        # Other ---------------------------------------------------------------
        self.kappa_dspinbox.setAlignment(qt_import.Qt.AlignRight)
        self.kappa_dspinbox.setFixedWidth(75)
        self.kappaphi_dspinbox.setAlignment(qt_import.Qt.AlignRight)
        self.kappaphi_dspinbox.setFixedWidth(75)

        self.step_cbox.setEditable(True)
        self.step_cbox.setValidator(
            qt_import.QDoubleValidator(0, 360, 5, self.step_cbox)
        )
        self.step_cbox.setDuplicatesEnabled(False)
        self.step_cbox.setFixedHeight(27)

        self.close_button.setIcon(icons.load_icon("Home2"))
        self.close_button.setFixedSize(27, 27)

        self.stop_button.setIcon(icons.load_icon("Stop2"))
        self.stop_button.setEnabled(False)
        self.stop_button.setFixedSize(27, 27)

        self.connect(HWR.beamline.diffractometer, "kappaMotorMoved", self.kappa_motor_moved)
        self.connect(HWR.beamline.diffractometer, "kappaPhiMotorMoved", self.kappaphi_motor_moved)
        self.connect(HWR.beamline.diffractometer, "minidiffStatusChanged", self.diffractometer_state_changed)
Esempio n. 24
0
    def __init__(self, *args):
        BaseWidget.__init__(self, *args)

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

        # Internal values -----------------------------------------------------
        self.cond_list = None
        self.states_list = None
        self.trans_list = None

        self.state_graph_node_list = []
        self.trans_graph_node_list = []
        self.condition_value_dict = {}

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

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

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

        # Graphic elements ----------------------------------------------------
        _cond_states_gbox = qt_import.QGroupBox(r"States \ conditions", self)
        self.splitter = qt_import.QSplitter(qt_import.Qt.Vertical, self)
        self.cond_states_table = qt_import.QTableWidget(self.splitter)
        self.log_treewidget = qt_import.QTreeWidget(self.splitter)
        self.graph_graphics_view = qt_import.QGraphicsView(self)
        self.graph_graphics_scene = qt_import.QGraphicsScene(self)

        self.check_icon = icons.load_icon("Check")
        self.reject_icon = icons.load_icon("Delete")

        # Layout --------------------------------------------------------------
        _cond_states_gbox_vlayout = qt_import.QVBoxLayout(_cond_states_gbox)
        _cond_states_gbox_vlayout.addWidget(self.splitter)
        _cond_states_gbox_vlayout.setSpacing(2)
        _cond_states_gbox_vlayout.setContentsMargins(2, 2, 2, 2)

        _main_vlayout = qt_import.QHBoxLayout(self)
        _main_vlayout.addWidget(_cond_states_gbox)
        _main_vlayout.addWidget(self.graph_graphics_view)
        _main_vlayout.setSpacing(2)
        _main_vlayout.setContentsMargins(2, 2, 2, 2)

        # Other ---------------------------------------------------------------
        self.cond_states_table.verticalHeader().setDefaultSectionSize(20)
        self.cond_states_table.horizontalHeader().setDefaultSectionSize(20)
        # setSelectionMode(qt_import.QAbstractItemView::SingleSelection);
        font = self.cond_states_table.font()
        font.setPointSize(8)
        self.cond_states_table.setFont(font)

        self.splitter.setSizes([200, 20])
        self.log_treewidget.setColumnCount(6)
        self.log_treewidget.setHeaderLabels([
            "State", "Start time", "End time", "Total time", "Previous state",
            "Notes"
        ])
        self.graph_graphics_view.setFixedSize(900, 600)
        self.graph_graphics_scene.setSceneRect(0, 0, 900, 600)
        self.graph_graphics_view.setScene(self.graph_graphics_scene)
        self.graph_graphics_view.setHorizontalScrollBarPolicy(
            qt_import.Qt.ScrollBarAlwaysOff)
        self.graph_graphics_view.setVerticalScrollBarPolicy(
            qt_import.Qt.ScrollBarAlwaysOff)
        self.graph_graphics_view.setDragMode(
            qt_import.QGraphicsView.RubberBandDrag)
        self.graph_graphics_view.setRenderHint(qt_import.QPainter.Antialiasing)
        self.graph_graphics_view.setRenderHint(
            qt_import.QPainter.TextAntialiasing)
Esempio n. 25
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.person = None
        self.laboratory = None
        # self.sessionId=None
        self.inhouseProposal = None
        self.instance_server_hwobj = None
        self.secondary_proposals = []

        # Properties ----------------------------------------------------------
        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)

        # 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 = qt_import.QGroupBox("ISPyB proposal", self)

        self.login_as_proposal_widget = qt_import.QWidget(self.main_gbox)
        code_label = qt_import.QLabel("  Code: ", self.login_as_proposal_widget)
        self.proposal_type_combox = qt_import.QComboBox(self.login_as_proposal_widget)
        self.proposal_type_combox.setEditable(True)
        self.proposal_type_combox.setFixedWidth(60)
        dash_label = qt_import.QLabel(" - ", self.login_as_proposal_widget)
        self.proposal_number_ledit = qt_import.QLineEdit(self.login_as_proposal_widget)
        self.proposal_number_ledit.setFixedWidth(60)
        password_label = qt_import.QLabel("   Password: "******"Login", self.login_as_proposal_widget)
        self.login_button.setFixedWidth(70)
        self.logout_button = qt_import.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 = qt_import.QWidget(self.main_gbox)
        self.proposal_combo = qt_import.QComboBox(self.login_as_user_widget)

        self.user_group_widget = qt_import.QWidget(self.main_gbox)
        # self.title_label = QtGui.QLabel(self.user_group_widget)
        # self.title_label.setAlignment(QtCore.Qt.AlignCenter)
        self.user_group_label = qt_import.QLabel("  Group: ", self.user_group_widget)
        self.user_group_ledit = qt_import.QLineEdit(self.user_group_widget)
        self.user_group_ledit.setFixedSize(100, 27)
        self.user_group_save_button = qt_import.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 = qt_import.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 = qt_import.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 = qt_import.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 = qt_import.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 = qt_import.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, qt_import.QPalette.Base
        )
        colors.set_widget_color(
            self.proposal_password_ledit, colors.LIGHT_RED, qt_import.QPalette.Base
        )