Esempio n. 1
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. 2
0
    def __init__(self, parent, realtime_plot=False):

        QtImport.QWidget.__init__(self, parent)

        self.snapshot_gbox = QtImport.QGroupBox("Snapshot", self)
        self.animation_gbox = QtImport.QGroupBox("Animation", self)
        self.snapshot_label = QtImport.QLabel(self.snapshot_gbox)
        self.animation_label = QtImport.QLabel(self.animation_gbox)

        # Layout --------------------------------------------------------------
        _snaphot_gbox_hlayout = QtImport.QHBoxLayout(self.snapshot_gbox)
        _snaphot_gbox_hlayout.addWidget(self.snapshot_label)
        _snaphot_gbox_hlayout.setContentsMargins(0, 0, 0, 0)

        _animation_gbox_hlayout = QtImport.QHBoxLayout(self.animation_gbox)
        _animation_gbox_hlayout.addWidget(self.animation_label)
        _animation_gbox_hlayout.setContentsMargins(0, 0, 0, 0)

        _main_vlayout = QtImport.QVBoxLayout(self)
        _main_vlayout.addWidget(self.snapshot_gbox)
        _main_vlayout.addWidget(self.animation_gbox)
        _main_vlayout.setSpacing(2)
        _main_vlayout.setContentsMargins(2, 2, 2, 2)
        _main_vlayout.addStretch(0)

        self.animation_gbox.setHidden(True)
Esempio n. 3
0
    def __init__(self, parent=None, name="scan_plot_widget"):

        QtImport.QWidget.__init__(self, parent)

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

        self.xdata = []
        self.ylabel = ""

        self.isRealTimePlot = None
        self.is_connected = None
        self.isScanning = None

        self.lblTitle = QtImport.QLabel(self)
        self.lblPosition = QtImport.QLabel(self)
        self.graph = QtBlissGraph(self)

        self.graph.canvas().setMouseTracking(True)
        self.graph.enableLegend(False)
        self.graph.enableZoom(False)
        _main_vlayout = QtImport.QVBoxLayout(self)
        _main_vlayout.addWidget(self.lblTitle)
        _main_vlayout.addWidget(self.lblPosition)
        _main_vlayout.addWidget(self.graph)
        _main_vlayout.setSpacing(2)
        _main_vlayout.setContentsMargins(0, 0, 0, 0)
Esempio n. 4
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

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

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

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

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

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

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

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

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

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

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

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

        self.connect(api.detector, "temperatureChanged", self.temperature_changed)
        self.connect(api.detector, "humidityChanged", self.humidity_changed)
        self.connect(api.detector, "statusChanged", self.status_changed)
        self.connect(api.detector, "frameRateChanged", self.frame_rate_changed)
Esempio n. 5
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

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

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

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

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

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

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

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

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

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

        # Other ---------------------------------------------------------------
        self._update_ledit_color(Colors.LIGHT_GREEN)
        self.validator = QtImport.QDoubleValidator(0, 100, 2,
                                                   self.new_value_ledit)
        self.new_value_ledit.setToolTip("Transmission limits 0 : 100 %")
        self.instance_synchronize("transmission_ledit", "new_value_ledit")

        if HWR.beamline.transmission is not None:
            # 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.connect(HWR.beamline.transmission, "stateChanged",
                         self._state_changed)
            self.connect(HWR.beamline.transmission, "valueChanged",
                         self._value_changed)
            self.connected()
        else:
            self.disconnected()
Esempio n. 6
0
    def __init__(self, parent, email_addresses, tab_label):
        QtImport.QWidget.__init__(self, parent)

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

        # Internal values -----------------------------------------------------
        self.tab_label = tab_label
        self.unread_messages = 0
        self.email_addresses = email_addresses
        self.from_email_address = None

        msg = [
            "Feel free to report any comment about this software;",
            " an email will be sent to the people concerned.",
            "Do not forget to put your name or email address if you require an answer.",
        ]
        # Properties ----------------------------------------------------------

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

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

        # Graphic elements ----------------------------------------------------
        __label = QtImport.QLabel("<b>%s</b>" % "\n".join(msg), self)
        __msg_label = QtImport.QLabel("Message:", self)

        self.submit_button = QtImport.QToolButton(self)
        self.message_textedit = QtImport.QTextEdit(self)

        # Layout --------------------------------------------------------------
        _main_vlayout = QtImport.QVBoxLayout(self)
        _main_vlayout.addWidget(__label)
        _main_vlayout.addWidget(__msg_label)
        _main_vlayout.addWidget(self.message_textedit)
        _main_vlayout.addWidget(self.submit_button)
        _main_vlayout.setSpacing(0)
        _main_vlayout.setContentsMargins(2, 2, 2, 2)

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

        # Qt signal/slot connections ------------------------------------------
        self.submit_button.clicked.connect(self.submit_message)

        # Other ---------------------------------------------------------------
        self.message_textedit.setToolTip("Write here your comments or feedback")
        self.submit_button.setText("Submit")

        # if hasattr(self.submit_button, "setUsesTextLabel"):
        #    self.submit_button.setUsesTextLabel(True)
        # elif hasattr(self.submit_button, "setToolButtonStyle"):
        #    self.submit_button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)

        self.submit_button.setToolButtonStyle(True)
        self.submit_button.setIcon(Icons.load_icon("Envelope"))
        self.submit_button.setToolTip(
            "Click here to send your feedback " + "to the authors of this software"
        )
    def __init__(self, parent=None, name=None, flags=0):

        QtImport.QWidget.__init__(self, parent, QtImport.Qt.WindowFlags(flags))

        if not name:
            self.setObjectName("RadiationDamageWidgetLayout")

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

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

        # Graphic elements ----------------------------------------------------
        self.rad_damage_cbx = QtImport.QCheckBox(self)
        _label_widget = QtImport.QWidget(self)
        self.burn_osc_start_label = QtImport.QLabel(_label_widget)
        self.burn_osc_start_ledit = QtImport.QLineEdit(_label_widget)
        self.burn_osc_start_ledit.setMinimumSize(50, 0)
        self.burn_osc_start_ledit.setMaximumSize(50, 32767)

        _value_widget = QtImport.QWidget(self)
        self.burn_osc_interval_label = QtImport.QLabel(_value_widget)
        self.burn_osc_interval_ledit = QtImport.QLineEdit(_value_widget)
        self.burn_osc_interval_ledit.setMinimumSize(50, 0)
        self.burn_osc_interval_ledit.setMaximumSize(50, 32767)

        # Layout --------------------------------------------------------------
        _label_widget_hlayout = QtImport.QHBoxLayout(self)
        _label_widget_hlayout.addWidget(self.burn_osc_start_label)
        _label_widget_hlayout.addWidget(self.burn_osc_start_ledit)
        _label_widget_hlayout.addStretch(0)
        _label_widget_hlayout.setSpacing(0)
        _label_widget_hlayout.setContentsMargins(0, 0, 0, 0)
        _label_widget.setLayout(_label_widget_hlayout)

        _value_hlayout = QtImport.QHBoxLayout(self)
        _value_hlayout.addWidget(self.burn_osc_interval_label)
        _value_hlayout.addWidget(self.burn_osc_interval_ledit)
        _value_hlayout.addStretch(0)
        _value_hlayout.setSpacing(0)
        _value_hlayout.setContentsMargins(0, 0, 0, 0)
        _value_widget.setLayout(_value_hlayout)

        _main_vlayout = QtImport.QVBoxLayout(self)
        _main_vlayout.addWidget(self.rad_damage_cbx)
        _main_vlayout.addWidget(_label_widget)
        _main_vlayout.addWidget(_value_widget)
        _main_vlayout.addStretch(0)
        _main_vlayout.setSpacing(0)
        _main_vlayout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(_main_vlayout)

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

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

        # Other ---------------------------------------------------------------
        self.languageChange()
Esempio n. 8
0
    def __init__(self, *args):
        BaseWidget.__init__(self, *args)

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

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

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

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

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

        # Graphic elements ----------------------------------------------------
        self.main_gbox = QtImport.QGroupBox("Beam size", self)
        hor_label = QtImport.QLabel("Horizontal:", self.main_gbox)
        self.hor_size_ledit = QtImport.QLineEdit(self.main_gbox)
        self.hor_size_ledit.setMaximumWidth(120)
        self.hor_size_ledit.setEnabled(False)
        self.hor_size_ledit.setAlignment(QtImport.Qt.AlignRight)

        ver_label = QtImport.QLabel("Vertical:", self.main_gbox)
        self.ver_size_ledit = QtImport.QLineEdit(self.main_gbox)
        self.ver_size_ledit.setMaximumWidth(120)
        self.ver_size_ledit.setEnabled(False)
        self.ver_size_ledit.setAlignment(QtImport.Qt.AlignRight)

        bold_font = self.hor_size_ledit.font()
        bold_font.setBold(True)
        self.hor_size_ledit.setFont(bold_font)
        self.ver_size_ledit.setFont(bold_font)

        # Layout --------------------------------------------------------------
        _main_gbox_gridlayout = QtImport.QGridLayout(self.main_gbox)
        _main_gbox_gridlayout.addWidget(hor_label, 0, 0)
        _main_gbox_gridlayout.addWidget(self.hor_size_ledit, 0, 1)
        _main_gbox_gridlayout.addWidget(ver_label, 1, 0)
        _main_gbox_gridlayout.addWidget(self.ver_size_ledit, 1, 1)
        _main_gbox_gridlayout.setRowStretch(2, 10)
        _main_gbox_gridlayout.setSpacing(2)
        _main_gbox_gridlayout.setContentsMargins(0, 0, 0, 0)

        _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 ------------------------------------------

        # Other ---------------------------------------------------------------

        self.connect(api.beam_info, "beamInfoChanged", self.beam_info_changed)
Esempio n. 9
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. 10
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

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

        # Internal variables --------------------------------------------------
        self.beamstop_limits = [0, 200]

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

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

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

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

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

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

        # Other ---------------------------------------------------------------
        Colors.set_widget_color(self.new_value_ledit, Colors.LINE_EDIT_ACTIVE,
                                QtImport.QPalette.Base)
        self.new_value_validator = QtImport.QDoubleValidator(
            0, 100, 2, self.new_value_ledit)
Esempio n. 11
0
    def __init__(self, *args):
        BaseWidget.__init__(self, *args)

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

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

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

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

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

        # Graphic elements ----------------------------------------------------
        self.progress_type_label = QtImport.QLabel("", self)
        self.progress_bar = QtImport.QProgressBar(self)
        # $self.progress_bar.setCenterIndicator(True)
        self.progress_bar.setMinimum(0)

        main_layout = QtImport.QVBoxLayout(self)
        main_layout.addWidget(self.progress_type_label)
        main_layout.addWidget(self.progress_bar)
        main_layout.setContentsMargins(2, 2, 2, 2)
        main_layout.setSpacing(2)
        self.setEnabled(False)

        new_palette = QtImport.QPalette()
        new_palette.setColor(QtImport.QPalette.Highlight, Colors.DARK_GREEN)
        self.progress_bar.setPalette(new_palette)
Esempio n. 12
0
    def __init__(self, parent, realtime_plot=False):

        QtImport.QWidget.__init__(self, parent)

        self.axis_x_array = []
        self.axis_y_array = []

        self.realtime_plot = realtime_plot

        self.pymca_graph = Plot(self)
        self.pymca_graph.showGrid()
        self.info_label = QtImport.QLabel("", self)
        self.info_label.setAlignment(QtImport.Qt.AlignRight)

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

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

        if PYMCA_EXISTS:
            QtImport.QObject.connect(
                self.pymca_graph,
                QtImport.SIGNAL("QtBlissGraphSignal"),
                self.handle_graph_signal,
            )

        Colors.set_widget_color(self, Colors.WHITE)
Esempio n. 13
0
    def __init__(self, parent=None):
        """"
        Constructor of MotorSlider

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

        self.values_format = "%+8.4f"  #"{0:8.4f}"

        # slider params:

        self.slider = QtImport.QSlider()
        self.slider.setEnabled(False)
        self.slider.setTickInterval(10)
        self.slider.setTickPosition(QtImport.QSlider.TicksBothSides)
        self.slider.setOrientation(QtImport.Qt.Horizontal)

        # extra controls
        min_value_text = self.values_format % self.slider.minimum()
        max_value_text = self.values_format % self.slider.maximum()
        current_value_text = self.values_format % self.slider.value()
        self.min_label = QtImport.QLabel(min_value_text)
        self.max_label = QtImport.QLabel(max_value_text)
        self.current_label = QtImport.QLabel(current_value_text)

        # layouts
        self.main_v_layout = QtImport.QVBoxLayout()
        self.labels_h_layout = QtImport.QHBoxLayout()

        self.labels_h_layout.addWidget(self.min_label)
        self.labels_h_layout.addStretch()
        self.labels_h_layout.addWidget(self.current_label)
        self.labels_h_layout.addStretch()
        self.labels_h_layout.addWidget(self.max_label)

        self.main_v_layout.addLayout(self.labels_h_layout)
        self.main_v_layout.addWidget(self.slider)

        self.setLayout(self.main_v_layout)

        # stylesheets
        self.slider.setStyleSheet(self.stylesheet1)

        self.slider.valueChanged.connect(self.value_changed)
Esempio n. 14
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. 15
0
    def __init__(self, fields, parent=None):
        QtImport.QWidget.__init__(self, parent)
        self.field_widgets = list()

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

        current_row = 0
        col_incr = 0
        pad = ""
        for field in fields:
            # should not happen but lets just skip them
            if field["type"] != "message" and "uiLabel" not in field:
                continue

            # hack until the 'real' xml gets implemented server side
            # and this mess gets rewritten
            if field["type"] == "message":
                logging.debug("creating widget with options: %s", field)
                widget = make_widget(self, field)
                # message will be alone in the layout
                # so that will not fsck up the layout
                self.layout().addWidget(widget, current_row, current_row, 0, 1)
            else:
                logging.debug("creating widget with options: %s", field)
                widget = make_widget(self, field)
                # Temporary (like this brick ...) hack to get a nicer UI
                if isinstance(widget, TextEdit):
                    widget.setSizePolicy(
                        QtImport.QSizePolicy.MinimumExpanding,
                        QtImport.QSizePolicy.Minimum,
                    )
                else:
                    widget.setSizePolicy(QtImport.QSizePolicy.Fixed,
                                         QtImport.QSizePolicy.Fixed)
                self.field_widgets.append(widget)
                if field["type"] == "boolean":
                    self.layout().addWidget(widget, current_row, 0 + col_incr,
                                            1, 2, QtImport.Qt.AlignLeft)
                else:
                    label = QtImport.QLabel(pad + field["uiLabel"], self)
                    self.layout().addWidget(label, current_row, 0 + col_incr,
                                            QtImport.Qt.AlignLeft)
                    self.layout().addWidget(widget, current_row, 1 + col_incr,
                                            QtImport.Qt.AlignLeft)

            current_row += 1
            if field.pop("NEW_COLUMN", False):
                # Increment column
                col_incr += 2
                current_row = 0
                pad = " " * 5
        self.update()
Esempio n. 16
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. 17
0
    def __init__(self, *args):
        BaseWidget.__init__(self, *args)

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

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

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

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

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

        # Graphic elements ----------------------------------------------------
        _main_groupbox = QtImport.QGroupBox("Image tracking", self)
        self.state_label = QtImport.QLabel("<b> </b>", _main_groupbox)
        self.image_tracking_cbox = QtImport.QCheckBox(
            "Enable Adxv image tracking", _main_groupbox
        )
        self.filter_frames_cbox = QtImport.QCheckBox(
            "Filter frames based on Dozor score", _main_groupbox
        )
        self.spot_list_cbox = QtImport.QCheckBox(
            "Indicate spots in ADxV", _main_groupbox
        )

        # Layout --------------------------------------------------------------
        _main_groupbox_vlayout = QtImport.QVBoxLayout(_main_groupbox)
        _main_groupbox_vlayout.addWidget(self.state_label)
        _main_groupbox_vlayout.addWidget(self.image_tracking_cbox)
        _main_groupbox_vlayout.addWidget(self.filter_frames_cbox)
        _main_groupbox_vlayout.addWidget(self.spot_list_cbox)
        _main_groupbox_vlayout.setSpacing(2)
        _main_groupbox_vlayout.setContentsMargins(4, 4, 4, 4)

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

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

        # Qt signal/slot connections ------------------------------------------
        self.image_tracking_cbox.toggled.connect(self.image_tracking_cbox_toggled)
        self.filter_frames_cbox.toggled.connect(self.filter_frames_cbox_toggled)
        self.spot_list_cbox.toggled.connect(self.spot_list_cbox_toggled)

        # Other ---------------------------------------------------------------
        self.state_label.setAlignment(QtImport.Qt.AlignCenter)
        self.state_label.setFixedHeight(24)
        self.state_changed("unknown")
Esempio n. 18
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. 19
0
    def __init__(self, parent=None, name=None, fl=0):

        QtImport.QWidget.__init__(self, parent, QtImport.Qt.WindowFlags(fl))
        if name is not None:
            self.setObjectName(name)
        self.selected_element = None
        self.selected_edge = "L3"

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

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

        # Graphic elements ----------------------------------------------------
        if PYMCA_IMPORTED:
            self.periodic_table = CustomPeriodicTable(self)
        else:
            self.periodic_elements_combo = QtImport.QComboBox(self)
            self.periodic_elements_combo.setFixedWidth(100)

        self.edge_widget = QtImport.QWidget(self)
        edge_label = QtImport.QLabel("Edge:", self.edge_widget)
        self.edge_combo = QtImport.QComboBox(self.edge_widget)

        # Layout --------------------------------------------------------------
        _edge_hlayout = QtImport.QHBoxLayout(self.edge_widget)
        if not PYMCA_IMPORTED:
            _edge_hlayout.addWidget(self.periodic_elements_combo)
        _edge_hlayout.addWidget(edge_label)
        _edge_hlayout.addWidget(self.edge_combo)
        _edge_hlayout.addStretch(0)
        _edge_hlayout.setSpacing(2)
        _edge_hlayout.setContentsMargins(0, 0, 0, 0)

        _main_vlayout = QtImport.QVBoxLayout(self)
        if PYMCA_IMPORTED:
            _main_vlayout.addWidget(self.periodic_table,
                                    QtImport.Qt.AlignHCenter)
        _main_vlayout.addWidget(self.edge_widget)
        _main_vlayout.addStretch(0)
        _main_vlayout.setSpacing(2)
        _main_vlayout.setContentsMargins(2, 2, 2, 2)

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

        # Qt signal/slot connections ------------------------------------------
        if PYMCA_IMPORTED:
            self.periodic_table.edgeSelectedSignal.connect(self.edge_selected)
        else:
            self.periodic_elements_combo.activated.connect(
                self.element_combo_activated)
        self.edge_combo.addItem("K")
        self.edge_combo.activated.connect(self.edge_combo_activated)
        self.edge_combo.setEnabled(False)
Esempio n. 20
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. 21
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. 22
0
    def __init__(self, parent, options):
        QtImport.QWidget.__init__(self, parent)
        logging.debug("making message with options %r", options)
        QtImport.QHBoxLayout(self)
        icon = QtImport.QLabel(self)
        icon.setSizePolicy(QtImport.QSizePolicy.Fixed,
                           QtImport.QSizePolicy.Fixed)

        # all the following stuff is there to get the standard icon
        # for our level directly from qt
        mapping = {
            "warning": QtImport.QMessageBox.Warning,
            "info": QtImport.QMessageBox.Information,
            "error": QtImport.QMessageBox.Critical,
        }
        level = mapping.get(options["level"])
        if level is not None:
            icon.setPixmap(QtImport.QMessageBox.standardIcon(level))

        text = QtImport.QLabel(options["text"], self)

        self.layout().addWidget(icon)
        self.layout().addWidget(text)
Esempio n. 23
0
    def __init__(self, parent, brick):

        QtImport.QGroupBox.__init__(self, "State", parent)
        BaseWidget.__init__(self, parent)
        # Graphic elements ----------------------------------------------------
        # self.contents_widget = QGroupBox("Sample Changer State", self)

        self._parent = brick
        self.status_label = QtImport.QLabel("")
        self.status_label.setAlignment(QtImport.Qt.AlignCenter)

        # Layout --------------------------------------------------------------

        _layout = QtImport.QHBoxLayout(self)
        _layout.addWidget(self.status_label)
        _layout.setSpacing(2)
        _layout.setContentsMargins(6, 6, 6, 10)
Esempio n. 24
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

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

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

        # Properties (name, type, default value, comment)----------------------

        # Properties for hwobj initialization ---------------------------------
        self.add_property("hwobj_flux", "string", "")

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

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

        # Graphic elements ----------------------------------------------------
        flux_label = QtImport.QLabel("Flux:", self)
        beam_label = QtImport.QLabel("Beam:", self)
        dose_label = QtImport.QLabel("Dose:", self)
        self.flux_value_label = QtImport.QLabel("-", self)
        self.beam_info_value_label = QtImport.QLabel("-", self)
        self.dose_value_label = QtImport.QLabel("-", self)

        # Layout --------------------------------------------------------------
        _groupbox_vlayout = QtImport.QGridLayout(self)
        _groupbox_vlayout.addWidget(flux_label, 0, 0)
        _groupbox_vlayout.addWidget(beam_label, 1, 0)
        _groupbox_vlayout.addWidget(dose_label, 2, 0)
        _groupbox_vlayout.addWidget(self.flux_value_label, 0, 1)
        _groupbox_vlayout.addWidget(self.beam_info_value_label, 1, 1)
        _groupbox_vlayout.addWidget(self.dose_value_label, 2, 1)
        _groupbox_vlayout.setSpacing(2)
        _groupbox_vlayout.setContentsMargins(0, 0, 0, 0)

        # SizePolicies --------------------------------------------------------
        flux_label.setMaximumWidth(40)
Esempio n. 25
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. 26
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. 27
0
    def __init__(self, parent=None, name="gphl_acquisition_widget"):
        GphlSetupWidget.__init__(self, parent=parent, name=name)

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

        _parameters_widget = self._parameters_widget

        row = 0
        field_name = "crystal_system"
        label_name = self._get_label_name(field_name)
        label_str = "Crystal system :"
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        widget = QtImport.QComboBox()
        _parameters_widget.layout().addWidget(widget, row, 1)
        self._widget_data[field_name] = (widget, str, None, 0)
        self._pulldowns[field_name] = list(self._CRYSTAL_SYSTEM_DATA)

        row += 1
        field_name = "space_group"
        label_name = self._get_label_name(field_name)
        label_str = "Space group :"
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        widget = QtImport.QComboBox()
        _parameters_widget.layout().addWidget(widget, row, 1)
        self._widget_data[field_name] = (widget, str, None, 0)

        row += 1
        field_name = "characterisation_strategy"
        label_name = self._get_label_name(field_name)
        label_str = "Characterisation strategy :"
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        widget = QtImport.QComboBox()
        _parameters_widget.layout().addWidget(widget, row, 1)
        self._widget_data[field_name] = (widget, str, None, 0)
        strategy_names = HWR.beamline.gphl_workflow.get_property(
            "characterisation_strategies").split()
        self._pulldowns[field_name] = strategy_names

        row += 1
        field_name = "dose_budget"
        label_name = self._get_label_name(field_name)
        label_str = "Dose budget (MGy) :"
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        widget = QtImport.QComboBox()
        _parameters_widget.layout().addWidget(widget, row, 1)
        self._widget_data[field_name] = (widget, str, None, 0)
        self._pulldowns[field_name] = list(
            HWR.beamline.gphl_workflow.dose_budgets)
        self._pulldown_defaults[
            field_name] = HWR.beamline.gphl_workflow.default_dose_budget_label
        indx = self._pulldowns[field_name].index(
            HWR.beamline.gphl_workflow.default_dose_budget_label)
        self._widget_data[field_name] = (widget, str, None, indx)

        row += 1
        field_name = "relative_rad_sensitivity"
        label_name = self._get_label_name(field_name)
        label_str = "Rel. radiation sensitivity"
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        widget = QtImport.QLineEdit()
        _parameters_widget.layout().addWidget(widget, row, 1)
        validator = QtImport.QDoubleValidator(0, 100, 4, widget)
        self._widget_data[field_name] = (widget, float, validator, 1.0)
Esempio n. 28
0
    def __init__(self, parent=None, name="gphl_acquisition_widget"):
        GphlSetupWidget.__init__(self, parent=parent, name=name)

        _parameters_widget = self._parameters_widget

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

        # Get test crystal data
        self.test_crystals = OrderedDict()
        xx0 = next(HWR.beamline.gphl_workflow.get_objects("test_crystals"))
        for test_crystal in xx0.get_objects("test_crystal"):
            dd0 = test_crystal.get_properties()
            self.test_crystals[dd0["name"]] = CrystalData(**dd0)

        row = 0
        field_name = "test_crystal"
        label_name = self._get_label_name(field_name)
        label_str = "Test Crystal :"
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        widget = QtImport.QComboBox()
        _parameters_widget.layout().addWidget(widget, row, 1)
        self._widget_data[field_name] = (widget, str, None, 0)
        self._pulldowns[field_name] = list(self.test_crystals)

        row += 1
        label_name = "test_crystal_spacegroup"
        label_str = " "
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        label_name = "test_crystal_parameters"
        label_str = " "
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 1)
        self._widget_data[label_name] = (label, str, None, label_str)

        row += 1
        field_name = "dose_budget"
        label_name = self._get_label_name(field_name)
        label_str = "Dose budget (MGy) :"
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        widget = QtImport.QComboBox()
        _parameters_widget.layout().addWidget(widget, row, 1)
        self._pulldowns[field_name] = list(
            HWR.beamline.gphl_workflow.dose_budgets)
        self._pulldown_defaults[
            field_name] = HWR.beamline.gphl_workflow.default_dose_budget_label
        indx = self._pulldowns[field_name].index(
            HWR.beamline.gphl_workflow.default_dose_budget_label)
        self._widget_data[field_name] = (widget, str, None, indx)

        row += 1
        field_name = "relative_rad_sensitivity"
        label_name = self._get_label_name(field_name)
        label_str = "Rel. radiation sensitivity"
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        widget = QtImport.QLineEdit()
        _parameters_widget.layout().addWidget(widget, row, 1)
        validator = QtImport.QDoubleValidator(0, 100, 4, widget)
        self._widget_data[field_name] = (widget, float, validator, 1.0)
Esempio n. 29
0
    def __init__(self, parent=None, name=None, fl=0):
        QtImport.QWidget.__init__(self, parent, QtImport.Qt.WindowFlags(fl))

        if not name:
            self.setObjectName("VerticalCrystalDimensionWidgetLayout")

        return

        VerticalCrystalDimensionWidgetLayoutLayout = QtImport.QVBoxLayout(
            self, 0, 6, "VerticalCrystalDimensionWidgetLayoutLayout")

        self.gbox = QtImport.QGroupBox(self, "gbox")
        self.gbox.setSizePolicy(QtImport.QSizePolicy.MinimumExpanding,
                                QtImport.QSizePolicy.MinimumExpanding)
        self.gbox.setChecked(0)
        self.gbox.setColumnLayout(0, QtImport.Qt.Vertical)
        self.gbox.layout().setSpacing(6)
        self.gbox.layout().setMargin(11)
        gboxLayout = QtImport.QHBoxLayout(self.gbox.layout())
        gboxLayout.setAlignment(QtImport.Qt.AlignTop)

        main_layout = QtImport.QVBoxLayout(None, 0, 15, "main_layout")

        space_group_layout = QtImport.QHBoxLayout(None, 0, 6,
                                                  "space_group_layout")

        space_group_ledit_layout = QtImport.QHBoxLayout(
            None, 0, 6, "space_group_ledit_layout")

        self.space_group_label = QtImport.QLabel(self.gbox,
                                                 "space_group_label")
        space_group_ledit_layout.addWidget(self.space_group_label)

        self.space_group_ledit = QtImport.QComboBox(0, self.gbox,
                                                    "space_group_ledit")
        self.space_group_ledit.setMinimumSize(QtImport.QSize(100, 0))
        self.space_group_ledit.setMaximumSize(QtImport.QSize(100, 32767))
        space_group_ledit_layout.addWidget(self.space_group_ledit)
        space_group_layout.addLayout(space_group_ledit_layout)
        space_group_hspacer = QtImport.QSpacerItem(
            1, 20, QtImport.QSizePolicy.Expanding,
            QtImport.QSizePolicy.Minimum)
        space_group_layout.addItem(space_group_hspacer)
        main_layout.addLayout(space_group_layout)

        vdim_layout = QtImport.QVBoxLayout(None, 0, 2, "vdim_layout")

        vdim_heading_layout = QtImport.QHBoxLayout(None, 0, 6,
                                                   "vdim_heading_layout")

        self.dimension_label = QtImport.QLabel(self.gbox, "dimension_label")
        vdim_heading_layout.addWidget(self.dimension_label)
        vdim_heading_spacer = QtImport.QSpacerItem(
            1, 20, QtImport.QSizePolicy.Expanding,
            QtImport.QSizePolicy.Minimum)
        vdim_heading_layout.addItem(vdim_heading_spacer)
        vdim_layout.addLayout(vdim_heading_layout)

        vdim_control_layout = QtImport.QHBoxLayout(None, 0, 0,
                                                   "vdim_control_layout")

        vdim_ledit_hlayout = QtImport.QHBoxLayout(None, 0, 20,
                                                  "vdim_ledit_hlayout")

        col_one_vdim_ledit_hlayout = QtImport.QHBoxLayout(
            None, 0, 6, "col_one_vdim_ledit_hlayout")

        vlayout_min_vdim_label = QtImport.QVBoxLayout(
            None, 0, 6, "vlayout_min_vdim_label")

        self.min_vdim_label = QtImport.QLabel(self.gbox, "min_vdim_label")
        vlayout_min_vdim_label.addWidget(self.min_vdim_label)

        self.vdim_min_phi_label = QtImport.QLabel(self.gbox,
                                                  "vdim_min_phi_label")
        vlayout_min_vdim_label.addWidget(self.vdim_min_phi_label)
        col_one_vdim_ledit_hlayout.addLayout(vlayout_min_vdim_label)

        vlayout_min_vdim_ledit = QtImport.QVBoxLayout(
            None, 0, 6, "vlayout_min_vdim_ledit")

        self.min_vdim_ledit = QtImport.QLineEdit(self.gbox, "min_vdim_ledit")
        self.min_vdim_ledit.setMinimumSize(QtImport.QSize(50, 0))
        self.min_vdim_ledit.setMaximumSize(QtImport.QSize(50, 32767))
        vlayout_min_vdim_ledit.addWidget(self.min_vdim_ledit)

        self.min_vphi_ledit = QtImport.QLineEdit(self.gbox, "min_vphi_ledit")
        self.min_vphi_ledit.setMinimumSize(QtImport.QSize(50, 0))
        self.min_vphi_ledit.setMaximumSize(QtImport.QSize(50, 32767))
        vlayout_min_vdim_ledit.addWidget(self.min_vphi_ledit)
        col_one_vdim_ledit_hlayout.addLayout(vlayout_min_vdim_ledit)
        vdim_ledit_hlayout.addLayout(col_one_vdim_ledit_hlayout)

        col_two_vdim_ledit_hlayout = QtImport.QHBoxLayout(
            None, 0, 6, "col_two_vdim_ledit_hlayout")

        vlayout_two_vdim_hlayout = QtImport.QVBoxLayout(
            None, 0, 6, "vlayout_two_vdim_hlayout")

        self.max_vdim_label = QtImport.QLabel(self.gbox, "max_vdim_label")
        vlayout_two_vdim_hlayout.addWidget(self.max_vdim_label)

        self.max_vphi_label = QtImport.QLabel(self.gbox, "max_vphi_label")
        vlayout_two_vdim_hlayout.addWidget(self.max_vphi_label)
        col_two_vdim_ledit_hlayout.addLayout(vlayout_two_vdim_hlayout)

        vlayout_max_vdim_ledit = QtImport.QVBoxLayout(
            None, 0, 6, "vlayout_max_vdim_ledit")

        self.max_vdim_ledit = QtImport.QLineEdit(self.gbox, "max_vdim_ledit")
        self.max_vdim_ledit.setMinimumSize(QtImport.QSize(50, 0))
        self.max_vdim_ledit.setMaximumSize(QtImport.QSize(50, 32767))
        vlayout_max_vdim_ledit.addWidget(self.max_vdim_ledit)

        self.max_vphi_ledit = QtImport.QLineEdit(self.gbox, "max_vphi_ledit")
        self.max_vphi_ledit.setMinimumSize(QtImport.QSize(50, 0))
        self.max_vphi_ledit.setMaximumSize(QtImport.QSize(50, 32767))
        vlayout_max_vdim_ledit.addWidget(self.max_vphi_ledit)
        col_two_vdim_ledit_hlayout.addLayout(vlayout_max_vdim_ledit)
        vdim_ledit_hlayout.addLayout(col_two_vdim_ledit_hlayout)
        vdim_control_layout.addLayout(vdim_ledit_hlayout)
        vspacer = QtImport.QSpacerItem(1, 20, QtImport.QSizePolicy.Expanding,
                                       QtImport.QSizePolicy.Minimum)
        vdim_control_layout.addItem(vspacer)
        vdim_layout.addLayout(vdim_control_layout)
        main_layout.addLayout(vdim_layout)
        gboxLayout.addLayout(main_layout)
        VerticalCrystalDimensionWidgetLayoutLayout.addWidget(self.gbox)

        self.languageChange()

        self.resize(
            QtImport.QSize(307, 163).expandedTo(self.minimumSizeHint()))
Esempio n. 30
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")