Esempio n. 1
0
    def __init__(self, parent=None, name=None, fl=0):
        QtImport.QDialog.__init__(self, parent, QtImport.Qt.WindowFlags(fl))

        if name is not None:
            self.setObjectName(name)

        # Internal variables --------------------------------------------------
        # AsyncResult to return values
        self._async_result = None

        # Layout
        QtImport.QVBoxLayout(self)
        main_layout = self.layout()
        main_layout.setSpacing(10)
        main_layout.setMargin(6)
        self.setSizePolicy(QtImport.QSizePolicy.Expanding,
                           QtImport.QSizePolicy.Expanding)

        self.setWindowTitle("GPhL Workflow parameters")

        # Info box
        self.info_gbox = QtImport.QGroupBox("Info", self)
        QtImport.QVBoxLayout(self.info_gbox)
        main_layout.addWidget(self.info_gbox)
        self.info_text = QtImport.QTextEdit(self.info_gbox)
        self.info_text.setFont(QtImport.QFont("Courier"))
        self.info_text.setReadOnly(True)
        self.info_gbox.layout().addWidget(self.info_text)

        # Special parameter box
        self.cplx_gbox = QtImport.QGroupBox("Indexing solution", self)
        QtImport.QVBoxLayout(self.cplx_gbox)
        main_layout.addWidget(self.cplx_gbox)
        self.cplx_gbox.setSizePolicy(QtImport.QSizePolicy.Expanding,
                                     QtImport.QSizePolicy.Expanding)
        self.cplx_widget = None

        # Parameter box
        self.parameter_gbox = QtImport.QGroupBox("Parameters", self)
        main_layout.addWidget(self.parameter_gbox)
        self.parameter_gbox.setSizePolicy(QtImport.QSizePolicy.Expanding,
                                          QtImport.QSizePolicy.Expanding)
        self.params_widget = None

        # Button bar
        button_layout = QtImport.QHBoxLayout(None)
        hspacer = QtImport.QSpacerItem(1, 20, QtImport.QSizePolicy.Expanding,
                                       QtImport.QSizePolicy.Minimum)
        button_layout.addItem(hspacer)
        self.continue_button = QtImport.QPushButton("Continue", self)
        button_layout.addWidget(self.continue_button)
        self.cancel_button = QtImport.QPushButton("Abort", self)
        button_layout.addWidget(self.cancel_button)
        main_layout.addLayout(button_layout)

        self.continue_button.clicked.connect(self.continue_button_click)
        self.cancel_button.clicked.connect(self.cancel_button_click)

        self.resize(
            QtImport.QSize(1018, 472).expandedTo(self.minimumSizeHint()))
Esempio n. 2
0
    def __init__(self, *args):

        MotorSpinBoxBrick.MotorSpinBoxBrick.__init__(self, *args)

        self.light_actuator_hwo = None
        self.light_saved_pos = None

        self.light_off_button = QtImport.QPushButton(self.main_gbox)
        self.light_off_button.setIcon(Icons.load_icon("BulbDelete"))
        self.light_off_button.setFixedSize(27, 27)

        self.light_on_button = QtImport.QPushButton(self.main_gbox)
        self.light_on_button.setIcon(Icons.load_icon("BulbCheck"))
        self.light_on_button.setFixedSize(27, 27)

        self.light_off_button.clicked.connect(self.light_button_off_clicked)
        self.light_on_button.clicked.connect(self.light_button_on_clicked)

        self._gbox_hbox_layout.addWidget(self.light_off_button)
        self._gbox_hbox_layout.addWidget(self.light_on_button)

        self.light_off_button.setToolTip(
            "Switches off the light and sets the intensity to zero"
        )
        self.light_on_button.setToolTip(
            "Switches on the light and sets the intensity back to the previous setting"
        )

        self.light_off_button.setSizePolicy(
            QtImport.QSizePolicy.Fixed, QtImport.QSizePolicy.Minimum
        )
        self.light_on_button.setSizePolicy(
            QtImport.QSizePolicy.Fixed, QtImport.QSizePolicy.Minimum
        )
Esempio n. 3
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 = QtImport.QGroupBox(self)
        self.enable_motors_buttons = QtImport.QPushButton("Enable", self.main_group_box)
        self.disable_motors_buttons = QtImport.QPushButton(
            "Disable", self.main_group_box
        )

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

        self.main_hlayout = QtImport.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. 4
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 = QtImport.QGroupBox(self)
        self.label = QtImport.QLabel("motor:", _main_gbox)
        self.positions_combo = QtImport.QComboBox(self)
        self.previous_position_button = QtImport.QPushButton(_main_gbox)
        self.next_position_button = QtImport.QPushButton(_main_gbox)

        # Layout --------------------------------------------------------------
        _main_gbox_hlayout = QtImport.QHBoxLayout(_main_gbox)
        _main_gbox_hlayout.addWidget(self.label)
        _main_gbox_hlayout.addWidget(self.positions_combo)
        _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 = QtImport.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.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. 5
0
    def __init__(self, parent=None):
        """"
        Constructor of MoveBox

        :param parent: MoveBox parent widget
        """
        super(MoveBox, self).__init__(parent)

        self.old_positions = []  # history of motor positions

        self.label_move = QtImport.QLabel("go to ", self)
        self.text_move = QtImport.QLineEdit("", self)
        self.cmd_move = QtImport.QPushButton("", self)
        self.cmd_move.setCheckable(True)
        self.cmd_go_back = QtImport.QPushButton("", self)
        self.cmd_stop = QtImport.QPushButton("", self)

        self.text_move.setFixedWidth(
            self.text_move.fontMetrics().width("8888.8888"))
        self.cmd_move.setCheckable(True)
        self.cmd_stop.setIcon(Icons.load_icon("stop_small"))
        self.cmd_stop.setEnabled(False)
        self.cmd_go_back.setIcon(Icons.load_icon("goback_small"))
        self.cmd_move.setIcon(Icons.load_icon("move_small"))
        self.cmd_go_back.setEnabled(False)

        # connections

        self.text_move.textChanged.connect(self.text_move_text_changed)
        self.cmd_move.clicked.connect(self.move_clicked)
        self.cmd_stop.clicked.connect(self.stop_motor_signal)
        self.text_move.returnPressed.connect(self.text_move_return_pressed)
        self.cmd_go_back.clicked.connect(self.go_back_clicked)

        # layout

        hboxlayout = QtImport.QHBoxLayout(self)

        hboxlayout.insertSpacerItem(
            0,
            QtImport.QSpacerItem(0, 0, QtImport.QSizePolicy.Expanding,
                                 QtImport.QSizePolicy.Fixed))

        hboxlayout.addWidget(self.label_move)
        hboxlayout.addWidget(self.text_move)
        hboxlayout.addWidget(self.cmd_move)
        hboxlayout.addWidget(self.cmd_go_back)
        hboxlayout.addWidget(self.cmd_stop)
        hboxlayout.insertSpacerItem(
            0,
            QtImport.QSpacerItem(0, 0, QtImport.QSizePolicy.Expanding,
                                 QtImport.QSizePolicy.Fixed))

        self.setLayout(hboxlayout)
Esempio n. 6
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)
Esempio n. 7
0
    def __init__(self, parent):

        QtImport.QDialog.__init__(self, parent)
        # Graphic elements-----------------------------------------------------
        # self.main_gbox = QtGui.QGroupBox('Motor step', self)
        # box2 = QtGui.QWidget(self)
        self.grid = QtImport.QWidget(self)
        label1 = QtImport.QLabel("Current:", self)
        self.current_step = QtImport.QLineEdit(self)
        self.current_step.setEnabled(False)
        label2 = QtImport.QLabel("Set to:", self)
        self.new_step = QtImport.QLineEdit(self)
        self.new_step.setAlignment(QtImport.Qt.AlignRight)
        self.new_step.setValidator(QtImport.QDoubleValidator(self))

        self.button_box = QtImport.QWidget(self)
        self.apply_button = QtImport.QPushButton("Apply", self.button_box)
        self.close_button = QtImport.QPushButton("Dismiss", self.button_box)

        # Layout --------------------------------------------------------------
        self.button_box_layout = QtImport.QHBoxLayout(self.button_box)
        self.button_box_layout.addWidget(self.apply_button)
        self.button_box_layout.addWidget(self.close_button)

        self.grid_layout = QtImport.QGridLayout(self.grid)
        self.grid_layout.addWidget(label1, 0, 0)
        self.grid_layout.addWidget(self.current_step, 0, 1)
        self.grid_layout.addWidget(label2, 1, 0)
        self.grid_layout.addWidget(self.new_step, 1, 1)

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

        # Qt signal/slot connections -----------------------------------------
        self.new_step.returnPressed.connect(self.apply_clicked)
        self.apply_button.clicked.connect(self.apply_clicked)
        self.close_button.clicked.connect(self.accept)

        # SizePolicies --------------------------------------------------------
        self.close_button.setSizePolicy(
            QtImport.QSizePolicy.Fixed, QtImport.QSizePolicy.Fixed
        )
        self.setSizePolicy(QtImport.QSizePolicy.Minimum, QtImport.QSizePolicy.Minimum)

        # Other ---------------------------------------------------------------
        self.setWindowTitle("Motor step editor")
        self.apply_button.setIcon(Icons.load_icon("Check"))
        self.close_button.setIcon(Icons.load_icon("Delete"))
Esempio n. 8
0
    def __init__(self, *args):
        QtImport.QWidget.__init__(self, *args)

        self.value_plot = None

        self.title_label = QtImport.QLabel(self)
        self.value_widget = QtImport.QWidget(self)
        self.value_label = QtImport.QLabel(self.value_widget)
        self.value_label.setAlignment(QtImport.Qt.AlignCenter)
        self.history_button = QtImport.QPushButton(
            Icons.load_icon("LineGraph"), "", self.value_widget)
        self.history_button.hide()
        self.history_button.setFixedWidth(22)
        self.history_button.setFixedHeight(22)

        _value_widget_hlayout = QtImport.QHBoxLayout(self.value_widget)
        _value_widget_hlayout.addWidget(self.value_label)
        _value_widget_hlayout.addWidget(self.history_button)
        _value_widget_hlayout.setSpacing(2)
        _value_widget_hlayout.setContentsMargins(0, 0, 0, 0)

        self.main_vlayout = QtImport.QVBoxLayout(self)
        self.main_vlayout.addWidget(self.title_label)
        self.main_vlayout.addWidget(self.value_widget)
        self.main_vlayout.setSpacing(1)
        self.main_vlayout.setContentsMargins(0, 0, 0, 0)

        self.history_button.clicked.connect(self.open_history_view)
Esempio n. 9
0
    def build_operations_widget(self):
        self.buttons_layout = QtImport.QHBoxLayout()
        self.operation_buttons_layout = QtImport.QVBoxLayout()

        self.load_button = QtImport.QPushButton("Load", self)
        self.unload_button = QtImport.QPushButton("Unload", self)
        self.abort_button = QtImport.QPushButton("Abort", self)

        self.load_button.clicked.connect(self.load_selected_sample)
        self.unload_button.clicked.connect(self.unload_selected_sample)
        self.abort_button.clicked.connect(self.abort_mounting)

        self.buttons_layout.addWidget(self.load_button)
        self.buttons_layout.addWidget(self.unload_button)
        self.operation_buttons_layout.addLayout(self.buttons_layout)
        self.operation_buttons_layout.addWidget(self.abort_button)
        self.operations_widget.setLayout(self.operation_buttons_layout)
Esempio n. 10
0
    def __init__(self, parent):

        QtImport.QWidget.__init__(self, parent)

        self.home_url = None

        self.navigation_bar = QtImport.QWidget(self)
        self.url_ledit = QtImport.QLineEdit(self.navigation_bar)
        self.url_ledit.setReadOnly(True)
        self.home_button = QtImport.QPushButton(self.navigation_bar)
        self.back_button = QtImport.QPushButton(self.navigation_bar)
        self.forward_button = QtImport.QPushButton(self.navigation_bar)

        self.home_button.setIcon(Icons.load_icon("Home2"))
        self.back_button.setIcon(Icons.load_icon("Left2"))
        self.forward_button.setIcon(Icons.load_icon("Right2"))

        #if QWEBVIEW_AVAILABLE:
        #    self.web_page_viewer = QtImport.QWebView(self)
        #    self.web_page_viewer.settings().setObjectCacheCapacities(0, 0, 0)
        #else:
        self.web_page_viewer = QtImport.QTextBrowser(self)

        _navigation_bar_hlayout = QtImport.QHBoxLayout(self.navigation_bar)
        _navigation_bar_hlayout.addWidget(self.home_button)
        _navigation_bar_hlayout.addWidget(self.back_button)
        _navigation_bar_hlayout.addWidget(self.forward_button)
        _navigation_bar_hlayout.addWidget(self.url_ledit)
        _navigation_bar_hlayout.setSpacing(2)
        _navigation_bar_hlayout.setContentsMargins(2, 2, 2, 2)

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

        self.web_page_viewer.setSizePolicy(QtImport.QSizePolicy.Expanding,
                                           QtImport.QSizePolicy.Expanding)

        self.home_button.clicked.connect(self.go_to_home_page)
        self.back_button.clicked.connect(self.go_back)
        self.forward_button.clicked.connect(self.go_forward)
Esempio n. 11
0
    def __init__(self, parent, row, col, color):
        QtImport.QWidget.__init__(self, parent)

        self.col = col
        self.row = row
        self.parent = parent

        self.change_color_button = QtImport.QPushButton("Color...", parent)
        self.reset_color_button = QtImport.QPushButton("reset", parent)

        main_layout = QtImport.QHBoxLayout(self)
        main_layout.addWidget(self.change_color_button)
        main_layout.addWidget(self.reset_color_button)
        main_layout.setSpacing(0)
        main_layout.setContentsMargins(0, 0, 0, 0)

        self.change_color_button.clicked.connect(self.change_color_clicked)
        self.reset_color_button.clicked.connect(self.reset_color_clicked)
        self.set_color(color)
Esempio n. 12
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

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

        # Signals ------------------------------------------------------------
        self.define_signal("incoming_unread_messages", ())
        self.define_signal("reset_unread_message", ())

        # Slots ---------------------------------------------------------------
        self.define_slot("tabSelected", ())
        self.define_slot("sessionSelected", ())

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

        # Internal values -----------------------------------------------------
        self.session_id = None
        self.nickname = ""
        self.role = BaseWidget.INSTANCE_ROLE_UNKNOWN

        # Graphic elements ----------------------------------------------------
        self.conversation_textedit = QtImport.QTextEdit(self)
        self.conversation_textedit.setReadOnly(True)
        _controls_widget = QtImport.QWidget(self)
        _say_label = QtImport.QLabel("Say:", _controls_widget)
        self.message_ledit = QtImport.QLineEdit(_controls_widget)
        self.send_button = QtImport.QPushButton("Send", _controls_widget)
        self.send_button.setEnabled(False)

        # Layout --------------------------------------------------------------
        _controls_widget_hlayout = QtImport.QHBoxLayout(_controls_widget)
        _controls_widget_hlayout.addWidget(_say_label)
        _controls_widget_hlayout.addWidget(self.message_ledit)
        _controls_widget_hlayout.addWidget(self.send_button)
        _controls_widget_hlayout.setSpacing(2)
        _controls_widget_hlayout.setContentsMargins(0, 0, 0, 0)

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

        # Qt signal/slot connections ------------------------------------------
        self.send_button.clicked.connect(self.send_current_message)
        self.message_ledit.returnPressed.connect(self.send_current_message)
        self.message_ledit.textChanged.connect(self.message_changed)
Esempio n. 13
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(
            HWR.beamline.hutch_interlock,
            "doorInterlockStateChanged",
            self.state_changed
        )
        HWR.beamline.hutch_interlock.re_emit_values()
Esempio n. 14
0
    def __init__(self,
                 parent,
                 button1="OK",
                 button2="Cancel",
                 button3=None,
                 callback=None,
                 margin=6,
                 spacing=6):
        """Constructor docstring."""
        super(DialogButtonsBar, self).__init__(parent)

        self.callback = callback
        spacer = QtImport.QWidget(self)
        spacer.setSizePolicy(QtImport.QSizePolicy.Expanding,
                             QtImport.QSizePolicy.Fixed)

        # Layout --------------------------------------------------------------
        self._dialog_vlayout = QtImport.QVBoxLayout(self, margin, spacing)
        self._dialog_vlayout.addWidget(spacer)

        if button1 is not None:
            self.button1 = QtImport.QPushButton(button1, self)
            self._dialog_vlayout.addWidget(self.button1)
            self.button1.clicked.connect(self.button1_clicked)

        if button2 is not None:
            self.button2 = QtImport.QPushButton(button1, self)
            self._dialog_vlayout.addWidget(self.button2)
            self.button2.clicked.connect(self.button2_clicked)

        if button3 is not None:
            self.button3 = QtImport.QPushButton(button1, self)
            self._dialog_vlayout.addWidget(self.button3)
            self.button3.clicked.connect(self.button3_clicked)

        self.setSizePolicy(QtImport.QSizePolicy.Minimum,
                           QtImport.QSizePolicy.Fixed)
        self.setLayout(self._dialog_vlayout)
Esempio n. 15
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

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

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

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

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

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

        # Graphic elements ----------------------------------------------------
        self.info_widget = QtImport.QWidget(self)
        self.info_address_ledit = QtImport.QLineEdit(self.info_widget)
        self.info_refresh_button = QtImport.QPushButton(
            "Refresh", self.info_widget)
        self.method_table = QtImport.QTableWidget(self)
        self.property_table = QtImport.QTableWidget(self)

        # Layout --------------------------------------------------------------
        _info_widget_hlayout = QtImport.QHBoxLayout(self.info_widget)
        _info_widget_hlayout.addWidget(self.info_address_ledit)
        _info_widget_hlayout.addWidget(self.info_refresh_button)

        _main_vlayout = QtImport.QVBoxLayout(self)
        _main_vlayout.addWidget(self.info_widget)
        _main_vlayout.addWidget(self.method_table)
        _main_vlayout.addWidget(self.property_table)
        _main_vlayout.setSpacing(2)
        _main_vlayout.setContentsMargins(2, 2, 2, 2)

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

        # Other ---------------------------------------------------------------
        self.method_table.setColumnCount(2)
        self.method_table.setHorizontalHeaderLabels(
            ["Type", "Method (Parameters)"])
        self.property_table.setColumnCount(4)
        self.property_table.setHorizontalHeaderLabels(
            ["Type", "Property", "Access", "Value"])
        self.setFixedWidth(600)
Esempio n. 16
0
    def __init__(self, parent, row, col, filename, file_filter):
        QtImport.QWidget.__init__(self)

        self.file_filter = file_filter
        self.parent = parent
        self.col = col
        self.row = row

        self.cmdBrowse = QtImport.QPushButton("Browse", self.parent.viewport())

        main_layout = QtImport.QHBoxLayout()
        main_layout.addWidget(self.cmdBrowse)
        main_layout.setSpacing(0)
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)

        self.cmdBrowse.clicked.connect(self.browse_clicked)
        self.set_filename(filename)
Esempio n. 17
0
    def __init__(self, parent, options):
        QtImport.QWidget.__init__(self, parent)

        # do not allow qt to stretch us vertically
        policy = self.sizePolicy()
        policy.setVerticalPolicy(QtImport.QSizePolicy.Fixed)
        self.setSizePolicy(policy)

        QtImport.QHBoxLayout(self)
        self.__name = options["variableName"]
        self.filepath = QtImport.QLineEdit(self)
        self.filepath.setAlignment(QtImport.Qt.AlignLeft)
        if "defaultValue" in options:
            self.filepath.setText(options["defaultValue"])
        self.open_dialog_btn = QtImport.QPushButton("...", self)
        self.open_dialog_btn.clicked.connect(self.open_file_dialog)

        self.layout().addWidget(self.filepath)
        self.layout().addWidget(self.open_dialog_btn)
Esempio n. 18
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

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

        # Properties ----------------------------------------------------------
        self.add_property("tunable-energy", "boolean", "True")

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

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

        # Graphic elements ----------------------------------------------------
        self.stacked_widget = QtImport.QStackedWidget(self)
        self.parameters_widget = CharParametersWidget(self)
        self.toggle_page_button = QtImport.QPushButton("View Results", self)
        self.toggle_page_button.setFixedWidth(100)

        self.results_view = WebViewWidget(self)
        self.stacked_widget.addWidget(self.parameters_widget)
        self.stacked_widget.addWidget(self.results_view)

        # Layout --------------------------------------------------------------
        _main_vlayout = QtImport.QVBoxLayout(self)
        _main_vlayout.addWidget(self.stacked_widget)
        # _main_vlayout.addStretch(0)
        _main_vlayout.addWidget(self.toggle_page_button)

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

        # Qt signal/slot connections ------------------------------------------
        self.toggle_page_button.clicked.connect(self.toggle_page)

        # Other ---------------------------------------------------------------
        self.stacked_widget.setCurrentWidget(self.parameters_widget)
        self.parameters_widget.collection_type = None
        self.toggle_page_button.setDisabled(True)
Esempio n. 19
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

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

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

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

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

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

        # Graphic elements ----------------------------------------------------
        self.group_box = QtImport.QGroupBox("Beam align", self)
        self.align_button = QtImport.QPushButton("Align", self.group_box)

        # Layout --------------------------------------------------------------
        _group_box_vlayout = QtImport.QVBoxLayout(self.group_box)
        _group_box_vlayout.addWidget(self.align_button)
        _group_box_vlayout.addStretch()
        _group_box_vlayout.setSpacing(0)
        _group_box_vlayout.setContentsMargins(0, 0, 0, 0)

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

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

        # Qt signal/slot connections ------------------------------------------
        self.align_button.clicked.connect(self.align_beam_clicked)
Esempio n. 20
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",
        )
Esempio n. 21
0
    def __init__(self, parent=None, name="task_toolbox"):

        QtImport.QWidget.__init__(self, parent)
        self.setObjectName = name

        # Internal variables --------------------------------------------------
        self.tree_brick = None
        self.previous_page_index = 0
        self.is_running = None
        self.path_conflict = False
        self.acq_conflict = False
        self.enable_collect = False
        self.create_task_widgets = {}

        # Graphic elements ----------------------------------------------------
        self.method_label = QtImport.QLabel("Collection method", self)
        self.method_label.setAlignment(QtImport.Qt.AlignCenter)

        self.tool_box = QtImport.QToolBox(self)
        self.tool_box.setObjectName("tool_box")
        # self.tool_box.setFixedWidth(600)

        self.discrete_page = CreateDiscreteWidget(self.tool_box, "Discrete")
        self.char_page = CreateCharWidget(self.tool_box, "Characterise")
        self.helical_page = CreateHelicalWidget(self.tool_box, "helical_page")
        self.energy_scan_page = CreateEnergyScanWidget(self.tool_box,
                                                       "energy_scan")
        self.xrf_spectrum_page = CreateXRFSpectrumWidget(
            self.tool_box, "xrf_spectrum")
        if HWR.beamline.gphl_workflow is not None:
            self.gphl_workflow_page = CreateGphlWorkflowWidget(
                self.tool_box, "gphl_workflow")
        else:
            self.gphl_workflow_page = None
        self.advanced_page = CreateAdvancedWidget(self.tool_box,
                                                  "advanced_scan")
        self.xray_imaging_page = CreateXrayImagingWidget(
            self.tool_box, "xray_imaging")
        self.still_scan_page = CreateStillScanWidget(self.tool_box,
                                                     "still_scan")

        self.tool_box.addItem(self.discrete_page, "Standard Collection")
        self.tool_box.addItem(self.char_page, "Characterisation")
        self.tool_box.addItem(self.helical_page, "Helical Collection")
        self.tool_box.addItem(self.energy_scan_page, "Energy Scan")
        self.tool_box.addItem(self.xrf_spectrum_page, "XRF Spectrum")
        if self.gphl_workflow_page is not None:
            self.tool_box.addItem(self.gphl_workflow_page, "GPhL Workflows")
        self.tool_box.addItem(self.advanced_page, "Advanced")
        self.tool_box.addItem(self.xray_imaging_page, "Xray Imaging")
        self.tool_box.addItem(self.still_scan_page, "Still")

        self.button_box = QtImport.QWidget(self)
        self.create_task_button = QtImport.QPushButton("  Add to queue",
                                                       self.button_box)
        self.create_task_button.setIcon(Icons.load_icon("add_row.png"))
        msg = "Add the collection method to the selected sample"
        self.create_task_button.setToolTip(msg)
        self.create_task_button.setEnabled(False)

        self.collect_now_button = QtImport.QPushButton("Collect Now",
                                                       self.button_box)
        self.collect_now_button.setIcon(Icons.load_icon("VCRPlay2.png"))
        self.collect_now_button.setToolTip(
            "Add the collection method to the queue and execute it")

        # Layout --------------------------------------------------------------
        _button_box_hlayout = QtImport.QHBoxLayout(self.button_box)
        _button_box_hlayout.addWidget(self.collect_now_button)
        _button_box_hlayout.addStretch(0)
        _button_box_hlayout.addWidget(self.create_task_button)
        _button_box_hlayout.setSpacing(0)
        _button_box_hlayout.setContentsMargins(0, 0, 0, 0)

        _main_vlayout = QtImport.QVBoxLayout(self)
        _main_vlayout.addWidget(self.method_label)
        _main_vlayout.addWidget(self.tool_box)
        _main_vlayout.addWidget(self.button_box)
        _main_vlayout.setSpacing(0)
        _main_vlayout.setContentsMargins(0, 0, 0, 0)

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

        # Qt signal/slot connections ------------------------------------------
        self.create_task_button.clicked.connect(self.create_task_button_click)
        self.collect_now_button.clicked.connect(self.collect_now_button_click)
        self.tool_box.currentChanged.connect(self.current_page_changed)

        for i in range(0, self.tool_box.count()):
            self.tool_box.widget(i).acqParametersConflictSignal.connect(
                self.acq_parameters_conflict_changed)
            self.tool_box.widget(i).pathTempleConflictSignal.connect(
                self.path_template_conflict_changed)

        # Other ---------------------------------------------------------------
        in_plate_mode = HWR.beamline.diffractometer.in_plate_mode()

        if (HWR.beamline.energy_scan is None or in_plate_mode
                or not HWR.beamline.tunable_wavelength):
            self.hide_task(self.energy_scan_page)
            logging.getLogger("HWR").info("Energy scan task not available")

        if HWR.beamline.xrf_spectrum is None or in_plate_mode:
            self.hide_task(self.xrf_spectrum_page)
            logging.getLogger("HWR").info("XRF spectrum task not available")

        if not HWR.beamline.imaging or in_plate_mode:
            self.hide_task(self.xray_imaging_page)
            logging.getLogger("HWR").info("Xray Imaging task not available")

        if HWR.beamline.gphl_connection and HWR.beamline.gphl_workflow:
            self.gphl_workflow_page.initialise_workflows()
        else:
            logging.getLogger("HWR").info("GPhL workflow task not available")
Esempio n. 22
0
    def __init__(self, parent=None, name=None, flags=0):
        QtImport.QDialog.__init__(
            self,
            parent,
            QtImport.Qt.WindowFlags(flags | QtImport.Qt.WindowStaysOnTopHint),
        )

        # Internal variables --------------------------------------------------
        self.camera_hwobj = None

        # Graphic elements ----------------------------------------------------
        self.contrast_slider = QtImport.QSlider(QtImport.Qt.Horizontal, self)
        self.contrast_doublespinbox = QtImport.QDoubleSpinBox(self)
        self.contrast_checkbox = QtImport.QCheckBox("auto", self)
        self.brightness_slider = QtImport.QSlider(QtImport.Qt.Horizontal, self)
        self.brightness_doublespinbox = QtImport.QDoubleSpinBox(self)
        self.brightness_checkbox = QtImport.QCheckBox("auto", self)
        self.gain_slider = QtImport.QSlider(QtImport.Qt.Horizontal, self)
        self.gain_doublespinbox = QtImport.QDoubleSpinBox(self)
        self.gain_checkbox = QtImport.QCheckBox("auto", self)
        self.gamma_slider = QtImport.QSlider(QtImport.Qt.Horizontal, self)
        self.gamma_doublespinbox = QtImport.QDoubleSpinBox(self)
        self.gamma_checkbox = QtImport.QCheckBox("auto", self)
        self.exposure_time_slider = QtImport.QSlider(QtImport.Qt.Horizontal,
                                                     self)
        self.exposure_time_doublespinbox = QtImport.QDoubleSpinBox(self)
        self.exposure_time_checkbox = QtImport.QCheckBox("auto", self)
        __close_button = QtImport.QPushButton("Close", self)

        # Layout --------------------------------------------------------------
        __main_gridlayout = QtImport.QGridLayout(self)
        __main_gridlayout.addWidget(QtImport.QLabel("Contrast:", self), 0, 0)
        __main_gridlayout.addWidget(self.contrast_slider, 0, 1)
        __main_gridlayout.addWidget(self.contrast_doublespinbox, 0, 2)
        __main_gridlayout.addWidget(self.contrast_checkbox, 0, 3)
        __main_gridlayout.addWidget(QtImport.QLabel("Brightness:", self), 1, 0)
        __main_gridlayout.addWidget(self.brightness_slider, 1, 1)
        __main_gridlayout.addWidget(self.brightness_doublespinbox, 1, 2)
        __main_gridlayout.addWidget(self.brightness_checkbox, 1, 3)
        __main_gridlayout.addWidget(QtImport.QLabel("Gain:", self), 2, 0)
        __main_gridlayout.addWidget(self.gain_slider, 2, 1)
        __main_gridlayout.addWidget(self.gain_doublespinbox, 2, 2)
        __main_gridlayout.addWidget(self.gain_checkbox, 2, 3)
        __main_gridlayout.addWidget(QtImport.QLabel("Gamma:", self), 3, 0)
        __main_gridlayout.addWidget(self.gamma_slider, 3, 1)
        __main_gridlayout.addWidget(self.gamma_doublespinbox, 3, 2)
        __main_gridlayout.addWidget(self.gamma_checkbox, 3, 3)
        __main_gridlayout.addWidget(
            QtImport.QLabel("Exposure time (ms):", self), 4, 0)
        __main_gridlayout.addWidget(self.exposure_time_slider, 4, 1)
        __main_gridlayout.addWidget(self.exposure_time_doublespinbox, 4, 2)
        __main_gridlayout.addWidget(self.exposure_time_checkbox, 4, 3)
        __main_gridlayout.addWidget(__close_button, 6, 2)
        __main_gridlayout.setSpacing(2)
        __main_gridlayout.setContentsMargins(5, 5, 5, 5)
        __main_gridlayout.setSizeConstraint(QtImport.QLayout.SetFixedSize)

        # Qt signal/slot connections ------------------------------------------
        self.contrast_slider.valueChanged.connect(self.set_contrast)
        self.contrast_doublespinbox.valueChanged.connect(self.set_contrast)
        self.contrast_checkbox.stateChanged.connect(self.set_contrast_auto)
        self.brightness_slider.valueChanged.connect(self.set_brightness)
        self.brightness_doublespinbox.valueChanged.connect(self.set_brightness)
        self.brightness_checkbox.stateChanged.connect(self.set_brightness_auto)
        self.gain_slider.valueChanged.connect(self.set_gain)
        self.gain_doublespinbox.valueChanged.connect(self.set_gain)
        self.gain_checkbox.stateChanged.connect(self.set_gain_auto)
        self.gamma_slider.valueChanged.connect(self.set_gamma)
        self.gamma_doublespinbox.valueChanged.connect(self.set_gamma)
        self.gamma_checkbox.stateChanged.connect(self.set_gamma_auto)
        self.exposure_time_slider.valueChanged.connect(self.set_exposure_time)
        self.exposure_time_doublespinbox.valueChanged.connect(
            self.set_exposure_time)
        self.exposure_time_checkbox.stateChanged.connect(
            self.set_exposure_time_auto)

        __close_button.clicked.connect(self.close)

        # SizePolicies --------------------------------------------------------
        self.contrast_slider.setFixedWidth(200)
        self.brightness_slider.setFixedWidth(200)
        self.gain_slider.setFixedWidth(200)
        self.gamma_slider.setFixedWidth(200)
        self.exposure_time_slider.setFixedWidth(200)
        __close_button.setSizePolicy(QtImport.QSizePolicy.Fixed,
                                     QtImport.QSizePolicy.Fixed)

        # Other ---------------------------------------------------------------
        self.setModal(True)
        self.setWindowTitle("Camera controls")
Esempio n. 23
0
    def __init__(self, *args):
        BaseWidget.__init__(self, *args)

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

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

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

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

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

        # Graphic elements ----------------------------------------------------
        self.main_gbox = QtImport.QGroupBox("Slits", self)  # h
        hor_label = QtImport.QLabel("Horizontal:", self.main_gbox)
        self.current_hor_pos_ledit = QtImport.QLineEdit(self.main_gbox)
        self.current_hor_pos_ledit.setAlignment(QtImport.Qt.AlignRight)
        boldFont = self.current_hor_pos_ledit.font()
        boldFont.setBold(True)
        self.current_hor_pos_ledit.setFont(boldFont)
        self.current_hor_pos_ledit.setMaximumWidth(120)
        self.current_hor_pos_ledit.setEnabled(False)
        self.hor_pos_dspinbox = QtImport.QSpinBox(self.main_gbox)
        # self.hor_pos_dspinbox.setMaximumWidth(120)
        # self.hor_pos_dspinbox.setEnabled(False)
        self.set_hor_gap_button = QtImport.QPushButton(
            Icons.load_icon("Draw"), "", self.main_gbox
        )
        # self.set_hor_gap_button.setEnabled(False)
        self.set_hor_gap_button.setFixedSize(27, 27)
        self.stop_hor_button = QtImport.QPushButton(
            Icons.load_icon("Stop2"), "", self.main_gbox
        )
        self.stop_hor_button.setEnabled(False)
        self.stop_hor_button.setFixedSize(27, 27)

        # Vertical gap
        ver_label = QtImport.QLabel("Vertical:", self.main_gbox)
        self.current_ver_pos_ledit = QtImport.QLineEdit(self.main_gbox)
        self.current_ver_pos_ledit.setAlignment(QtImport.Qt.AlignRight)
        self.current_ver_pos_ledit.setFont(boldFont)
        self.current_ver_pos_ledit.setMaximumWidth(120)
        self.current_ver_pos_ledit.setEnabled(False)
        self.ver_pos_dspinbox = QtImport.QSpinBox(self.main_gbox)
        # self.ver_pos_dspinbox.setMaximumWidth(70)
        # self.ver_pos_dspinbox.setEnabled(False)
        self.set_ver_gap_button = QtImport.QPushButton(
            Icons.load_icon("Draw"), "", self.main_gbox
        )
        # self.set_ver_gap_button.setEnabled(False)
        self.set_ver_gap_button.setFixedSize(27, 27)
        self.stop_ver_button = QtImport.QPushButton(
            Icons.load_icon("Stop2"), "", self.main_gbox
        )
        self.stop_ver_button.setEnabled(False)
        self.stop_ver_button.setFixedSize(27, 27)

        self.test_button = QtImport.QPushButton("Test", self.main_gbox)
        self.test_button.hide()

        # Layout --------------------------------------------------------------
        _main_gbox_gridlayout = QtImport.QGridLayout(self.main_gbox)
        _main_gbox_gridlayout.addWidget(hor_label, 0, 0)
        _main_gbox_gridlayout.addWidget(self.current_hor_pos_ledit, 0, 1)
        _main_gbox_gridlayout.addWidget(self.hor_pos_dspinbox, 0, 2)
        _main_gbox_gridlayout.addWidget(self.set_hor_gap_button, 0, 3)
        _main_gbox_gridlayout.addWidget(self.stop_hor_button, 0, 4)
        _main_gbox_gridlayout.addWidget(ver_label, 1, 0)
        _main_gbox_gridlayout.addWidget(self.current_ver_pos_ledit, 1, 1)
        _main_gbox_gridlayout.addWidget(self.ver_pos_dspinbox, 1, 2)
        _main_gbox_gridlayout.addWidget(self.set_ver_gap_button, 1, 3)
        _main_gbox_gridlayout.addWidget(self.stop_ver_button, 1, 4)
        _main_gbox_gridlayout.setSpacing(2)
        _main_gbox_gridlayout.setContentsMargins(0, 0, 0, 0)

        _main_gbox_gridlayout.addWidget(self.test_button, 0, 5)

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

        # Qt signal/slot connections ------------------------------------------
        hor_spinbox_event = SpinBoxEvent(self.hor_pos_dspinbox)
        self.hor_pos_dspinbox.installEventFilter(hor_spinbox_event)
        hor_spinbox_event.returnPressedSignal.connect(self.change_hor_gap)

        self.hor_pos_dspinbox.lineEdit().textChanged.connect(self.hor_gap_edited)
        self.set_hor_gap_button.clicked.connect(self.change_hor_gap)
        self.stop_hor_button.clicked.connect(self.stop_hor_clicked)

        ver_spinbox_event = SpinBoxEvent(self.ver_pos_dspinbox)
        self.ver_pos_dspinbox.installEventFilter(ver_spinbox_event)
        ver_spinbox_event.returnPressedSignal.connect(self.change_ver_gap)

        self.ver_pos_dspinbox.lineEdit().textChanged.connect(self.ver_gap_edited)
        self.ver_pos_dspinbox.lineEdit().returnPressed.connect(self.change_ver_gap)
        self.set_ver_gap_button.clicked.connect(self.change_ver_gap)
        self.stop_ver_button.clicked.connect(self.stop_ver_clicked)

        self.test_button.clicked.connect(self.test_clicked)

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

        # Other ---------------------------------------------------------------
        self.current_hor_pos_ledit.setToolTip("Current horizontal gap size")
        self.set_hor_gap_button.setToolTip("Set new horizontal gap size")
        self.stop_hor_button.setToolTip("Stop horizontal slits movements")
        self.current_ver_pos_ledit.setToolTip("Current vertical gap size")
        self.set_ver_gap_button.setToolTip("Set new vertical gap size")
        self.stop_ver_button.setToolTip("Stop vertical slits movements")
Esempio n. 24
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 = QtImport.QGroupBox("CRL", self)
        self.mode_combo = QtImport.QComboBox(self.main_gbox)
        self.set_according_to_energy_button = QtImport.QPushButton(
            "Set", self.main_gbox)
        self.set_out_button = QtImport.QPushButton("Out", self.main_gbox)
        # self.align_beam_button = QtImport.QtGui.QPushButton("Align", self.main_gbox)

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

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

        # Layout --------------------------------------------------------------
        _crl_widget_hlayout = QtImport.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 = QtImport.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 = QtImport.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. 25
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 = QtImport.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 = QtImport.QWidget(self)
        _load_last_test_button = QtImport.QPushButton("View last results",
                                                      _web_view_widget)
        self.test_result_browser = WebViewWidget(_web_view_widget)

        # Layout --------------------------------------------------------------
        _web_view_widget_vlayout = QtImport.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 = QtImport.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(QtImport.QSizePolicy.Expanding,
                                               QtImport.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. 26
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

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

        # Internal values -----------------------------------------------------
        self.step_editor = None
        self.move_step = 1
        self.demand_move = 0
        self.in_expert_mode = None
        self.position_history = []

        # Properties ----------------------------------------------------------
        self.add_property("mnemonic", "string", "")
        self.add_property("formatString", "formatString", "+##.##")
        self.add_property("label", "string", "")
        self.add_property("showLabel", "boolean", True)
        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("showStepList", "boolean", False)
        self.add_property("showPosition", "boolean", True)
        self.add_property("invertButtons", "boolean", False)
        self.add_property("oneClickPressButton", "boolean", False)
        self.add_property("delta", "string", "")
        self.add_property("decimals", "integer", 2)
        self.add_property("icons", "string", "")
        self.add_property("helpDecrease", "string", "")
        self.add_property("helpIncrease", "string", "")
        self.add_property("hideInUser", "boolean", False)
        self.add_property("defaultSteps", "string", "180 90 45 30 10")
        self.add_property("enableSliderTracking", "boolean", False)

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

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

        # Graphic elements-----------------------------------------------------
        self.main_gbox = QtImport.QGroupBox(self)
        self.motor_label = QtImport.QLabel(self.main_gbox)
        self.motor_label.setFixedHeight(27)

        # Main controls
        self.move_left_button = QtImport.QPushButton(self.main_gbox)
        self.move_left_button.setIcon(Icons.load_icon("Left2"))
        self.move_left_button.setToolTip("Moves the motor down (while pressed)")
        self.move_left_button.setFixedSize(27, 27)
        self.move_left_button.setAutoRepeatDelay(500)
        self.move_left_button.setAutoRepeatInterval(500)
        self.move_right_button = QtImport.QPushButton(self.main_gbox)
        self.move_right_button.setIcon(Icons.load_icon("Right2"))
        self.move_right_button.setToolTip("Moves the motor up (while pressed)")
        self.move_right_button.setFixedSize(27, 27)
        self.move_right_button.setAutoRepeatDelay(500)
        self.move_right_button.setAutoRepeatInterval(500)
        self.position_spinbox = QtImport.QDoubleSpinBox(self.main_gbox)
        self.position_spinbox.setMinimum(-10000)
        self.position_spinbox.setMaximum(10000)
        self.position_spinbox.setFixedSize(75, 27)
        self.position_spinbox.setDecimals(3)
        self.position_spinbox.setToolTip(
            "Moves the motor to a specific "
            + "position or step by step; right-click for motor history"
        )
        self.position_spinbox.setContextMenuPolicy(QtImport.Qt.CustomContextMenu)

        # Extra controls
        self.stop_button = QtImport.QPushButton(self.main_gbox)
        self.stop_button.setIcon(Icons.load_icon("Stop2"))
        self.stop_button.setEnabled(False)
        self.stop_button.setToolTip("Stops the motor")
        self.stop_button.setFixedSize(27, 27)

        self.step_button = QtImport.QPushButton(self.main_gbox)
        self.step_button_icon = Icons.load_icon("TileCascade2")
        self.step_button.setIcon(self.step_button_icon)
        self.step_button.setToolTip("Changes the motor step")
        self.step_button.setFixedSize(27, 27)

        self.step_combo = QtImport.QComboBox(self.main_gbox)
        self.step_combo.setEditable(True)
        self.step_combo.setValidator(
            QtImport.QDoubleValidator(0, 360, 5, self.step_combo)
        )
        self.step_combo.setDuplicatesEnabled(False)
        self.step_combo.setFixedHeight(27)

        self.position_slider = QtImport.QDoubleSlider(
            QtImport.Qt.Horizontal, self.main_gbox
        )

        # Layout --------------------------------------------------------------
        self._gbox_hbox_layout = QtImport.QHBoxLayout(self.main_gbox)
        self._gbox_hbox_layout.addWidget(self.motor_label)
        self._gbox_hbox_layout.addWidget(self.position_spinbox)
        self._gbox_hbox_layout.addWidget(self.move_left_button)
        self._gbox_hbox_layout.addWidget(self.move_right_button)
        self._gbox_hbox_layout.addWidget(self.position_slider)
        self._gbox_hbox_layout.addWidget(self.stop_button)
        self._gbox_hbox_layout.addWidget(self.step_button)
        self._gbox_hbox_layout.addWidget(self.step_combo)
        self._gbox_hbox_layout.setSpacing(2)
        self._gbox_hbox_layout.setContentsMargins(2, 2, 2, 2)

        self._main_hbox_layout = QtImport.QVBoxLayout(self)
        self._main_hbox_layout.addWidget(self.main_gbox)
        self._main_hbox_layout.setSpacing(0)
        self._main_hbox_layout.setContentsMargins(0, 0, 0, 0)

        # SizePolicy (horizontal, vertical) -----------------------------------
        # self.setSizePolicy(QSizePolicy.Fixed,
        #                   QSizePolicy.Fixed)

        # Object events ------------------------------------------------------
        spinbox_event = SpinBoxEvent(self.position_spinbox)
        self.position_spinbox.installEventFilter(spinbox_event)
        spinbox_event.returnPressedSignal.connect(self.change_position)
        spinbox_event.contextMenuSignal.connect(self.open_history_menu)
        self.position_spinbox.lineEdit().textEdited.connect(self.position_value_edited)
        
        self.step_combo.activated.connect(self.go_to_step)
        self.step_combo.activated.connect(self.step_changed)
        self.step_combo.editTextChanged.connect(self.step_edited)

        self.stop_button.clicked.connect(self.stop_motor)
        self.step_button.clicked.connect(self.open_step_editor)

        self.move_left_button.pressed.connect(self.move_down)
        self.move_left_button.released.connect(self.stop_moving)
        self.move_right_button.pressed.connect(self.move_up)
        self.move_right_button.released.connect(self.stop_moving)

        self.position_slider.doubleValueChanged.connect(
            self.position_slider_double_value_changed
        )

        # Other ---------------------------------------------------------------
        self.instance_synchronize("position_spinbox", "step_combo")
Esempio n. 27
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.update_values()
                    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 = QtImport.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. 28
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("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")

        # 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)
Esempio n. 29
0
    def __init__(self, *args):
        BaseWidget.__init__(self, *args)

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

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

        # Properties ----------------------------------------------------------
        self.add_property("mnemonic", "string", "")
        self.add_property("forceNoControl", "boolean", False)
        self.add_property("expertModeControlOnly", "boolean", False)
        self.add_property("icons", "string", "")
        self.add_property("in", "string", "in")
        self.add_property("out", "string", "out")
        self.add_property("setin", "string", "Set in")
        self.add_property("setout", "string", "Set out")
        self.add_property("username", "string", "")

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

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

        # Graphic elements ----------------------------------------------------
        self.main_gbox = QtImport.QGroupBox("none", self)
        self.main_gbox.setAlignment(QtImport.Qt.AlignCenter)
        self.state_ledit = QtImport.QLineEdit("unknown", self.main_gbox)

        self.buttons_widget = QtImport.QWidget(self.main_gbox)
        self.set_in_button = QtImport.QPushButton("Set in",
                                                  self.buttons_widget)
        self.set_in_button.setCheckable(True)
        self.set_out_button = QtImport.QPushButton("Set out",
                                                   self.buttons_widget)
        self.set_out_button.setCheckable(True)

        # Layout --------------------------------------------------------------
        _buttons_widget_hlayout = QtImport.QHBoxLayout(self.buttons_widget)
        _buttons_widget_hlayout.addWidget(self.set_in_button)
        _buttons_widget_hlayout.addWidget(self.set_out_button)
        _buttons_widget_hlayout.setSpacing(0)
        _buttons_widget_hlayout.setContentsMargins(0, 0, 0, 0)

        _main_gbox_vlayout = QtImport.QVBoxLayout(self.main_gbox)
        _main_gbox_vlayout.addWidget(self.state_ledit)
        _main_gbox_vlayout.addWidget(self.buttons_widget)
        _main_gbox_vlayout.setSpacing(2)
        _main_gbox_vlayout.setContentsMargins(4, 4, 4, 4)

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

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

        # Qt signal/slot connections ------------------------------------------
        self.set_in_button.toggled.connect(self.set_in)
        self.set_out_button.toggled.connect(self.set_out)

        # Other ---------------------------------------------------------------
        self.state_ledit.setAlignment(QtImport.Qt.AlignCenter)
        self.state_ledit.setToolTip("Shows the current control state")
        self.state_ledit.setFrame(False)
        bold_font = self.state_ledit.font()
        bold_font.setBold(True)
        self.state_ledit.setFont(bold_font)
        self.state_ledit.setFixedHeight(24)

        self.set_in_button.setToolTip("Changes the control state")
        self.set_out_button.setToolTip("Changes the control state")

        self.instance_synchronize("state_ledit")
Esempio n. 30
0
    def __init__(self, *args):
        """
        Based on BaseWidget
        :param args:
        """

        BaseWidget.__init__(self, *args)

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

        # Internal values -----------------------------------------------------
        self.beam_focusing_hwobj = None
        self.beamline_test_hwobj = None
        self.unf_hor_motor = None
        self.unf_ver_motor = None
        self.double_hor_motor = None
        self.double_ver_motor = None
        self.motor_widget_list = []
        self.focus_mode = None
        self.is_beam_location_phase = False

        # Properties ----------------------------------------------------------
        self.add_property("hwobj_beam_focusing", "string", "")
        self.add_property("hwobj_beamline_test", "string", "/beamline-test")
        self.add_property("hwobj_motors_list", "string", "")
        self.add_property("icon_list", "string", "")
        self.add_property("defaultSteps", "string", "")
        self.add_property("defaultDeltas", "string", "")
        self.add_property("defaultDecimals", "string", "")
        self.add_property("enableCenterBeam", "boolean", True)
        self.add_property("enableMeasureFlux", "boolean", True)
        self.add_property("compactView", "boolean", False)

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

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

        # Graphic elements ----------------------------------------------------
        self.main_group_box = QtImport.QGroupBox(self)
        self.unf_hor_motor_brick = MotorSpinBoxBrick(self.main_group_box)
        self.unf_ver_motor_brick = MotorSpinBoxBrick(self.main_group_box)
        self.double_hor_motor_brick = MotorSpinBoxBrick(self.main_group_box)
        self.double_ver_motor_brick = MotorSpinBoxBrick(self.main_group_box)
        self.motor_widget_list = (
            self.unf_hor_motor_brick,
            self.unf_ver_motor_brick,
            self.double_hor_motor_brick,
            self.double_ver_motor_brick,
        )
        self.center_beam_button = QtImport.QPushButton(self.main_group_box)
        self.center_beam_button.setFixedSize(27, 27)
        self.measure_flux_button = QtImport.QPushButton(self.main_group_box)
        self.measure_flux_button.setFixedSize(27, 27)

        # Layout --------------------------------------------------------------
        _gbox_grid_layout = QtImport.QGridLayout(self.main_group_box)
        _gbox_grid_layout.addWidget(self.unf_hor_motor_brick, 0, 0)
        _gbox_grid_layout.addWidget(self.unf_ver_motor_brick, 1, 0)
        _gbox_grid_layout.addWidget(self.double_hor_motor_brick, 0, 1)
        _gbox_grid_layout.addWidget(self.double_ver_motor_brick, 1, 1)
        _gbox_grid_layout.addWidget(self.center_beam_button, 0, 2)
        _gbox_grid_layout.addWidget(self.measure_flux_button, 1, 2)
        _gbox_grid_layout.setSpacing(2)
        _gbox_grid_layout.setContentsMargins(2, 2, 2, 2)

        _main_hlayout = QtImport.QHBoxLayout(self)
        _main_hlayout.addWidget(self.main_group_box)
        _main_hlayout.setSpacing(0)
        _main_hlayout.setContentsMargins(0, 0, 0, 0)

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

        # Qt signal/slot connections ------------------------------------------
        self.center_beam_button.clicked.connect(self.center_beam_clicked)
        self.measure_flux_button.clicked.connect(self.measure_flux_clicked)

        # Other ---------------------------------------------------------------
        self.unf_hor_motor_brick.set_label("Horizontal")
        self.unf_ver_motor_brick.set_label("Vertical")
        self.double_hor_motor_brick.set_label("Horizontal")
        self.double_ver_motor_brick.set_label("Vertical")

        self.unf_hor_motor_brick.setEnabled(False)
        self.unf_ver_motor_brick.setEnabled(False)
        self.double_hor_motor_brick.setEnabled(False)
        self.double_ver_motor_brick.setEnabled(False)

        self.double_hor_motor_brick.setVisible(False)
        self.double_ver_motor_brick.setVisible(False)

        self.center_beam_button.setToolTip("Start center beam procedure")
        self.center_beam_button.setIcon(Icons.load_icon("QuickRealign"))
        self.measure_flux_button.setToolTip("Measure flux")
        self.measure_flux_button.setIcon(Icons.load_icon("Sun"))

        self.connect(api.diffractometer, "minidiffPhaseChanged",
                     self.phase_changed)

        api.diffractometer.update_values()
        self.update_gui()