def __init__(self, *args): BaseWidget.__init__(self, *args) # Hardware objects ---------------------------------------------------- # Internal values ----------------------------------------------------- # Properties ---------------------------------------------------------- # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Graphic elements ---------------------------------------------------- self.main_gbox = qt_import.QGroupBox("Aperture", self) self.aperture_diameter_combo = qt_import.QComboBox(self.main_gbox) self.aperture_diameter_combo.setMinimumWidth(100) self.aperture_position_combo = qt_import.QComboBox(self.main_gbox) self.aperture_position_combo.setMinimumWidth(100) # Layout -------------------------------------------------------------- _main_gbox_vlayout = qt_import.QVBoxLayout(self.main_gbox) _main_gbox_vlayout.addWidget(self.aperture_diameter_combo) _main_gbox_vlayout.addWidget(self.aperture_position_combo) _main_gbox_vlayout.addStretch() _main_gbox_vlayout.setSpacing(2) _main_gbox_vlayout.setContentsMargins(0, 0, 0, 0) _main_vlayout = qt_import.QVBoxLayout(self) _main_vlayout.addWidget(self.main_gbox) _main_vlayout.setSpacing(0) # _main_vlayout.addSpacing(0) _main_vlayout.setContentsMargins(2, 2, 2, 2) # Qt signal/slot connections ------------------------------------------ self.aperture_diameter_combo.activated.connect(self.change_diameter) self.aperture_position_combo.activated.connect(self.change_position) # SizePolicies -------------------------------------------------------- # Other --------------------------------------------------------------- colors.set_widget_color( self.aperture_diameter_combo, colors.LIGHT_GREEN, qt_import.QPalette.Button ) colors.set_widget_color( self.aperture_position_combo, colors.LIGHT_GREEN, qt_import.QPalette.Button ) self.aperture_diameter_combo.setMinimumWidth(100) self.aperture_position_combo.setMinimumWidth(100) self.init_aperture() self.connect( HWR.beamline.beam.aperture, "diameterIndexChanged", self.diameter_changed ) self.connect( HWR.beamline.beam.aperture, "valueChanged", self.position_changed )
def __init__(self, parent=None, name=None, fl=0): qt_import.QWidget.__init__(self, parent, qt_import.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 = qt_import.QComboBox(self) self.periodic_elements_combo.setFixedWidth(100) self.edge_widget = qt_import.QWidget(self) edge_label = qt_import.QLabel("Edge:", self.edge_widget) self.edge_combo = qt_import.QComboBox(self.edge_widget) # Layout -------------------------------------------------------------- _edge_hlayout = qt_import.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 = qt_import.QVBoxLayout(self) if PYMCA_IMPORTED: _main_vlayout.addWidget(self.periodic_table, qt_import.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)
def __init__(self, *args): BaseWidget.__init__(self, *args) # Hardware objects ---------------------------------------------------- self.motor_hwobj = None # Internal values ----------------------------------------------------- self.positions = None # Properties ---------------------------------------------------------- self.add_property("label", "string", "") self.add_property("mnemonic", "string", "") self.add_property("icons", "string", "") self.add_property("showMoveButtons", "boolean", True) # Signals ------------------------------------------------------------- # Slots --------------------------------------------------------------- self.define_slot("setEnabled", ()) # Graphic elements ---------------------------------------------------- _main_gbox = qt_import.QGroupBox(self) self.label = qt_import.QLabel("motor:", _main_gbox) self.positions_combo = qt_import.QComboBox(self) self.previous_position_button = qt_import.QPushButton(_main_gbox) self.next_position_button = qt_import.QPushButton(_main_gbox) # Layout -------------------------------------------------------------- _main_gbox_hlayout = qt_import.QHBoxLayout(_main_gbox) _main_gbox_hlayout.addWidget(self.label) _main_gbox_hlayout.addWidget(self.positions_combo) _main_gbox_hlayout.addWidget(self.previous_position_button) _main_gbox_hlayout.addWidget(self.next_position_button) _main_gbox_hlayout.setSpacing(2) _main_gbox_hlayout.setContentsMargins(2, 2, 2, 2) _main_hlayout = qt_import.QHBoxLayout(self) _main_hlayout.addWidget(_main_gbox) _main_hlayout.setSpacing(0) _main_hlayout.setContentsMargins(0, 0, 0, 0) # Size Policy --------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ self.positions_combo.activated.connect(self.position_selected) self.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)
def _initialize_graphics(self): # Graphic elements ---------------------------------------------------- self._workflow_type_widget = qt_import.QGroupBox("Workflow type", self) self._workflow_cbox = qt_import.QComboBox(self._workflow_type_widget) self._gphl_acq_widget = qt_import.QGroupBox("Acquisition", self) self._gphl_acq_param_widget = GphlAcquisitionWidget( self._gphl_acq_widget, "gphl_acquisition_parameter_widget") self._gphl_diffractcal_widget = GphlDiffractcalWidget( self._gphl_acq_widget, "gphl_diffractcal_widget") self._data_path_widget = DataPathWidget(self, "create_dc_path_widget", layout="vertical") data_path_layout = self._data_path_widget.data_path_layout data_path_layout.file_name_label.hide() data_path_layout.file_name_value_label.hide() data_path_layout.run_number_label.hide() data_path_layout.run_number_ledit.hide() data_path_layout.folder_ledit.setReadOnly(True) # Layout -------------------------------------------------------------- _workflow_type_vlayout = qt_import.QVBoxLayout( self._workflow_type_widget) _workflow_type_vlayout.addWidget(self._workflow_cbox) _gphl_acq_vlayout = qt_import.QVBoxLayout(self._gphl_acq_widget) _gphl_acq_vlayout.addWidget(self._gphl_acq_param_widget) _gphl_acq_vlayout.addWidget(self._gphl_diffractcal_widget) _main_vlayout = qt_import.QVBoxLayout(self) _main_vlayout.addWidget(self._workflow_type_widget) _main_vlayout.addWidget(self._data_path_widget) _main_vlayout.addWidget(self._gphl_acq_widget) _main_vlayout.addStretch(0) _main_vlayout.setSpacing(2) _main_vlayout.setContentsMargins(0, 0, 0, 0) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ self._workflow_cbox.currentIndexChanged.connect(self.workflow_selected) # set up popup data dialog self.gphl_data_dialog = GphlDataDialog(self, "GPhL Workflow Data") self.gphl_data_dialog.setModal(True) self.gphl_data_dialog.continueClickedSignal.connect(self.data_acquired)
def __init__(self, *args): BaseWidget.__init__(self, *args) # Internal values ----------------------------------------------------- # Properties ---------------------------------------------------------- self.add_property("confirmPhaseChange", "boolean", False) # Properties to initialize hardware objects -------------------------- # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Graphic elements ---------------------------------------------------- self.group_box = qt_import.QGroupBox("Phase", self) self.phase_combobox = qt_import.QComboBox(self.group_box) # Layout -------------------------------------------------------------- _group_box_vlayout = qt_import.QVBoxLayout(self.group_box) _group_box_vlayout.addWidget(self.phase_combobox) _group_box_vlayout.addStretch() _group_box_vlayout.setSpacing(2) _group_box_vlayout.setContentsMargins(0, 0, 0, 0) _main_vlayout = qt_import.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.phase_combobox.activated.connect(self.change_phase) # Other --------------------------------------------------------------- colors.set_widget_color(self.phase_combobox, colors.LIGHT_GREEN, qt_import.QPalette.Button) self.init_phase_list() self.connect(HWR.beamline.diffractometer, "minidiffPhaseChanged", self.phase_changed)
def __init__(self, *args): BaseWidget.__init__(self, *args) # Hardware objects ---------------------------------------------------- self.beam_focusing_hwobj = None # Internal values ----------------------------------------------------- # Properties ---------------------------------------------------------- self.add_property("mnemonic", "string", "") # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Graphic elements ---------------------------------------------------- _main_groupbox = qt_import.QGroupBox("Beamline mode", self) self.beam_focusing_combo = qt_import.QComboBox(_main_groupbox) self.beam_focusing_combo.setMinimumWidth(100) # Layout -------------------------------------------------------------- _main_groupbox_vlayout = qt_import.QVBoxLayout(_main_groupbox) _main_groupbox_vlayout.addWidget(self.beam_focusing_combo) _main_groupbox_vlayout.addStretch() _main_groupbox_vlayout.setSpacing(2) _main_groupbox_vlayout.setContentsMargins(2, 2, 2, 2) _main_vlayout = qt_import.QVBoxLayout(self) _main_vlayout.addWidget(_main_groupbox) _main_vlayout.setSpacing(0) _main_vlayout.setContentsMargins(2, 2, 2, 2) # Qt signal/slot connections ------------------------------------------ self.beam_focusing_combo.activated.connect(self.change_focus_mode) # SizePolicies -------------------------------------------------------- # Other --------------------------------------------------------------- colors.set_widget_color(self.beam_focusing_combo, colors.LIGHT_GREEN, qt_import.QPalette.Button)
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 = qt_import.QGroupBox("Resolution", self) current_label = qt_import.QLabel("Current:", self.group_box) current_label.setFixedWidth(75) self.resolution_ledit = qt_import.QLineEdit(self.group_box) self.resolution_ledit.setReadOnly(True) self.detector_distance_ledit = qt_import.QLineEdit(self.group_box) self.detector_distance_ledit.setReadOnly(True) _new_value_widget = qt_import.QWidget(self) set_to_label = qt_import.QLabel("Set to:", self.group_box) self.new_value_ledit = qt_import.QLineEdit(self.group_box) self.units_combobox = qt_import.QComboBox(_new_value_widget) self.stop_button = qt_import.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 = qt_import.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 = qt_import.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 = qt_import.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, qt_import.QPalette.Base) self.new_value_validator = qt_import.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", )
def __init__(self, *args): BaseWidget.__init__(self, *args) # Properties ---------------------------------------------------------- self.add_property("defaultMode", "combo", ("keV", "Ang"), "keV") self.add_property("kevFormatString", "formatString", "##.####") self.add_property("angFormatString", "formatString", "##.####") self.add_property("displayStatus", "boolean", False) self.add_property("doBeamAlignment", "boolean", False) # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Hardware objects ---------------------------------------------------- # Internal values ----------------------------------------------------- # Graphic elements ---------------------------------------------------- self.group_box = qt_import.QGroupBox("Energy", self) energy_label = qt_import.QLabel("Current:", self.group_box) energy_label.setFixedWidth(75) wavelength_label = qt_import.QLabel("Wavelength: ", self.group_box) self.energy_ledit = qt_import.QLineEdit(self.group_box) self.energy_ledit.setReadOnly(True) self.wavelength_ledit = qt_import.QLineEdit(self.group_box) self.wavelength_ledit.setReadOnly(True) self.status_label = qt_import.QLabel("Status:", self.group_box) self.status_label.setEnabled(False) self.status_ledit = qt_import.QLineEdit(self.group_box) self.status_ledit.setEnabled(False) self.new_value_widget = qt_import.QWidget(self) self.set_to_label = qt_import.QLabel("Set to: ", self) self.new_value_ledit = qt_import.QLineEdit(self.new_value_widget) # self.new_value_ledit.setMaximumWidth(60) self.units_combobox = qt_import.QComboBox(self.new_value_widget) self.units_combobox.addItems(["keV", u"\u212B"]) self.stop_button = qt_import.QPushButton(self.new_value_widget) self.stop_button.setIcon(icons.load_icon("Stop2")) self.stop_button.setEnabled(False) self.stop_button.setFixedWidth(25) self.beam_align_cbox = qt_import.QCheckBox( "Center beam after energy change", self) # Layout -------------------------------------------------------------- _new_value_widget_hlayout = qt_import.QHBoxLayout( self.new_value_widget) _new_value_widget_hlayout.addWidget(self.new_value_ledit) _new_value_widget_hlayout.addWidget(self.units_combobox) _new_value_widget_hlayout.addWidget(self.stop_button) _new_value_widget_hlayout.setSpacing(0) _new_value_widget_hlayout.setContentsMargins(0, 0, 0, 0) _group_box_gridlayout = qt_import.QGridLayout(self.group_box) _group_box_gridlayout.addWidget(energy_label, 0, 0) _group_box_gridlayout.addWidget(self.energy_ledit, 0, 1) _group_box_gridlayout.addWidget(wavelength_label, 1, 0) _group_box_gridlayout.addWidget(self.wavelength_ledit, 1, 1) _group_box_gridlayout.addWidget(self.status_label, 2, 0) _group_box_gridlayout.addWidget(self.status_ledit, 2, 1) _group_box_gridlayout.addWidget(self.set_to_label, 3, 0) _group_box_gridlayout.addWidget(self.new_value_widget, 3, 1) _group_box_gridlayout.addWidget(self.beam_align_cbox, 4, 0, 1, 2) _group_box_gridlayout.setSpacing(0) _group_box_gridlayout.setContentsMargins(1, 1, 1, 1) _main_vlayout = qt_import.QVBoxLayout(self) _main_vlayout.setSpacing(0) _main_vlayout.setContentsMargins(0, 0, 2, 2) _main_vlayout.addWidget(self.group_box) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ self.new_value_ledit.returnPressed.connect(self.current_value_changed) self.new_value_ledit.textChanged.connect(self.input_field_changed) self.units_combobox.activated.connect(self.units_changed) self.stop_button.clicked.connect(self.stop_clicked) self.beam_align_cbox.stateChanged.connect(self.do_beam_align_changed) # Other --------------------------------------------------------------- # self.group_box.setCheckable(True) # self.group_box.setChecked(True) self.new_value_validator = qt_import.QDoubleValidator( 0, 15, 4, self.new_value_ledit) self.status_ledit.setEnabled(False) self.set_new_value_limits() self.connect(HWR.beamline.energy, "energyChanged", self.energy_changed) self.connect(HWR.beamline.energy, "stateChanged", self.state_changed) self.connect(HWR.beamline.energy, "statusInfoChanged", self.status_info_changed) if hasattr(HWR.beamline.energy, "set_do_beam_alignment"): HWR.beamline.energy.set_do_beam_alignment(self["doBeamAlignment"]) if HWR.beamline.energy.is_ready(): tunable_energy = HWR.beamline.energy.is_tunable if tunable_energy is None: tunable_energy = False self.set_to_label.setEnabled(tunable_energy) self.new_value_ledit.setEnabled(tunable_energy) self.units_combobox.setEnabled(tunable_energy) if tunable_energy: colors.set_widget_color(self.new_value_ledit, colors.LINE_EDIT_ACTIVE, qt_import.QPalette.Base) else: self.setEnabled(False) self.instance_synchronize("energy_ledit", "new_value_ledit")
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 = [] self.editing = False self.units = None self.show_units = None # 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) self.add_property("show_units", "boolean", False) self.add_property("unit", "string", "mm") # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- self.define_slot("toggle_enabled", ()) # Graphic elements----------------------------------------------------- self.main_gbox = qt_import.QGroupBox(self) self.motor_label = qt_import.QLabel(self.main_gbox) self.motor_label.setFixedHeight(27) # Main controls self.move_left_button = qt_import.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 = qt_import.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 = qt_import.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( qt_import.Qt.CustomContextMenu) # Extra controls self.stop_button = qt_import.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 = qt_import.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 = qt_import.QComboBox(self.main_gbox) self.step_combo.setEditable(True) self.step_combo.setValidator( qt_import.QDoubleValidator(0, 360, 5, self.step_combo)) self.step_combo.setDuplicatesEnabled(False) self.step_combo.setFixedHeight(27) self.position_slider = qt_import.QDoubleSlider(qt_import.Qt.Horizontal, self.main_gbox) # Layout -------------------------------------------------------------- self._gbox_hbox_layout = qt_import.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 = qt_import.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")
def __init__(self, *args): BaseWidget.__init__(self, *args) # Hardware objects ---------------------------------------------------- # Internal values ----------------------------------------------------- self.current_chip_config = None self.info_dict = { "collect_grid_cell": -1, "collect_comp_cell": -1, "processing_grid_cell": -1, "processing_comp_cell": -1 } self.params_dict = None self.results = None self.collect_frame_num = 0 self.processing_frame_num = 0 self.score_type = "score" self.score_type_list = ("score", "spots_resolution", "spots_num") self.grid_table_item_fixed = False self.comp_table_item_fixed = False # Properties ---------------------------------------------------------- self.add_property("cell_size", "integer", 22) # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Graphic elements ---------------------------------------------------- self.grid_widget = qt_import.QWidget(self) self.grid_table = qt_import.QTableWidget(self.grid_widget) self.grid_cell_label = qt_import.QLabel("Selected grid cell: A1", self.grid_widget) self.chip_config_combo = qt_import.QComboBox(self) self.inverted_rows_cbox = qt_import.QCheckBox("Inverted rows", self.grid_widget) self.image_tracking_cbox = qt_import.QCheckBox("Live update", self.grid_widget) self.score_type_combo = qt_import.QComboBox(self.grid_widget) self.show_grid_dialog_button = qt_import.QPushButton( "Full grid view", self.grid_widget) self.comp_widget = qt_import.QWidget(self) self.comp_cell_label = qt_import.QLabel( "Selected compartment cell: A1", self.comp_widget) self.comp_table = qt_import.QTableWidget(self.comp_widget) self.hit_map_plot = PlotWidget(self.comp_widget) self.grid_dialog = qt_import.QDialog(self) self.grid_graphics_view = GraphicsView() self.grid_graphics_base = GridViewGraphicsItem() self.grid_graphics_overlay = GridViewOverlayItem() # self.grid_graphics_view.scene().setSceneRect(0, 0, 2000, 2000) self.grid_graphics_view.scene().addItem(self.grid_graphics_base) self.grid_graphics_view.scene().addItem(self.grid_graphics_overlay) self.save_grid_view_button = qt_import.QPushButton( "Save", self.grid_dialog) self.save_grid_view_button.setFixedWidth(100) # Layout -------------------------------------------------------------- _grid_vlayout = qt_import.QVBoxLayout(self.grid_widget) _grid_vlayout.addWidget(self.grid_cell_label) _grid_vlayout.addWidget(self.grid_table) _grid_vlayout.addStretch() _grid_vlayout.addWidget(self.chip_config_combo) _grid_vlayout.addWidget(self.inverted_rows_cbox) _grid_vlayout.addWidget(self.image_tracking_cbox) _grid_vlayout.addWidget(self.score_type_combo) _grid_vlayout.addWidget(self.show_grid_dialog_button) _grid_vlayout.setSpacing(2) _grid_vlayout.setContentsMargins(2, 2, 2, 2) _comp_vlayout = qt_import.QVBoxLayout(self.comp_widget) _comp_vlayout.addWidget(self.comp_cell_label) _comp_vlayout.addWidget(self.comp_table) _comp_vlayout.addWidget(self.hit_map_plot) _comp_vlayout.setSpacing(2) _comp_vlayout.setContentsMargins(2, 2, 2, 2) _main_vlayout = qt_import.QHBoxLayout(self) _main_vlayout.addWidget(self.grid_widget) _main_vlayout.addWidget(self.comp_widget) _main_vlayout.setSpacing(2) _main_vlayout.setContentsMargins(2, 2, 2, 2) _main_grid_dialog_vlayout = qt_import.QVBoxLayout(self.grid_dialog) _main_grid_dialog_vlayout.addWidget(self.grid_graphics_view) _main_grid_dialog_vlayout.addWidget(self.save_grid_view_button) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ self.grid_table.cellClicked.connect(self.grid_cell_clicked) self.grid_table.cellEntered.connect(self.grid_cell_entered) self.comp_table.cellClicked.connect(self.comp_cell_clicked) self.comp_table.cellEntered.connect(self.comp_cell_entered) self.chip_config_combo.activated.connect( self.grid_properties_combo_changed) self.score_type_combo.activated.connect(self.score_type_changed) self.show_grid_dialog_button.clicked.connect(self.show_grid_dialog) self.hit_map_plot.mouseMovedSignal.connect(self.hit_map_mouse_moved) self.grid_graphics_view.mouseMovedSignal.connect( self.grid_view_mouse_moved) self.save_grid_view_button.clicked.connect(self.save_grid_view) # Other --------------------------------------------------------------- self.grid_table.setEditTriggers( qt_import.QAbstractItemView.NoEditTriggers) self.grid_table.setHorizontalScrollBarPolicy( qt_import.Qt.ScrollBarAlwaysOff) self.grid_table.setVerticalScrollBarPolicy( qt_import.Qt.ScrollBarAlwaysOff) self.grid_table.setMouseTracking(True) self.comp_table.setEditTriggers( qt_import.QAbstractItemView.NoEditTriggers) self.comp_table.setHorizontalScrollBarPolicy( qt_import.Qt.ScrollBarAlwaysOff) self.comp_table.setVerticalScrollBarPolicy( qt_import.Qt.ScrollBarAlwaysOff) self.comp_table.setMouseTracking(True) for score_type in ("Score", "Resolution", "Number of spots"): self.score_type_combo.addItem(score_type) HWR.beamline.online_processing.connect("processingStarted", self.processing_started) HWR.beamline.online_processing.connect("processingFinished", self.processing_finished) HWR.beamline.online_processing.connect("processingFailed", self.processing_failed) HWR.beamline.online_processing.connect("processingFrame", self.processing_frame_changed) self.current_grid_properties = ( HWR.beamline.online_processing.get_current_grid_properties()) self.grid_properties_combo.blockSignals(True) for prop in HWR.beamline.online_processing.get_available_grid_properties( ): self.grid_properties_combo.addItem(str(prop)) self.grid_properties_combo.setCurrentIndex(0) self.grid_properties_combo.blockSignals(False) self.init_gui() self.grid_graphics_base.init_item(self.current_chip_config) self.grid_graphics_overlay.init_item(self.current_chip_config)
def __init__(self, parent=None): qt_import.QWidget.__init__(self, parent) self.setObjectName("hit_map_widget") # Properties ---------------------------------------------------------- # Signals ------------------------------------------------------------- # Slots --------------------------------------------------------------- # Internal values ----------------------------------------------------- self.__result_types = [] self.__results_raw = None self.__results_aligned = None self.__first_result = True self.__grid = None #self.__is_mesh_scan = False self.__data_collection = None self.__selected_col = 0 self.__selected_row = 0 self.__score_key = None self.__max_value = 0 self.__filter_min_value = 0 self.__best_pos_list = None self.__hitmap_clicked = False self.__enable_continues_image_display = False #self.__tooltip_text = None self.selected_image_serial = None # Graphic elements ---------------------------------------------------- self._hit_map_gbox = qt_import.QGroupBox("Online processing results", self) hit_maps_widget = qt_import.QWidget(self._hit_map_gbox) self._osc_hit_map_plot = PlotWidget(hit_maps_widget) self._osc_hit_map_plot.set_plot_type("1D") self._grid_hit_map_plot = PlotWidget(hit_maps_widget) self._grid_hit_map_plot.set_plot_type("2D") self._hit_map_popup_menu = qt_import.QMenu(self._hit_map_gbox) hit_map_info_widget = qt_import.QWidget(self._hit_map_gbox) score_type_label = qt_import.QLabel("Result: ", hit_map_info_widget) self._score_type_cbox = qt_import.QComboBox(hit_map_info_widget) self._autoscale_button = qt_import.QPushButton("Auto scale", hit_map_info_widget) image_display_cbox = qt_import.QCheckBox("Display image in ADxV", hit_map_info_widget) self._image_info_label = qt_import.QLabel("Image: #, value #", hit_map_info_widget) self._hit_map_tools_widget = qt_import.QWidget(self._hit_map_gbox) _threshold_label = qt_import.QLabel("Threshold: ", self._hit_map_tools_widget) self._threshold_slider = qt_import.QSlider(qt_import.Qt.Horizontal, self._hit_map_tools_widget) self._relaunch_processing_button = qt_import.QPushButton( "Relaunch processing", self._hit_map_tools_widget) self._create_points_button = qt_import.QPushButton( "Create centring points", self._hit_map_tools_widget) """ self._summary_gbox = qt_import.QGroupBox("Summary", self) self._summary_textbrowser = qt_import.QTextBrowser(self._summary_gbox) self._best_pos_gbox = qt_import.QGroupBox("Best positions", self) self._best_pos_table = qt_import.QTableWidget(self._best_pos_gbox) self._best_pos_popup_menu = qt_import.QMenu(self._hit_map_gbox) self._best_pos_gbox.setHidden(True) """ # Layout -------------------------------------------------------------- _hit_map_info_hlayout = qt_import.QHBoxLayout(hit_map_info_widget) _hit_map_info_hlayout.addWidget(score_type_label) _hit_map_info_hlayout.addWidget(self._score_type_cbox) _hit_map_info_hlayout.addWidget(self._autoscale_button) _hit_map_info_hlayout.addWidget(image_display_cbox) _hit_map_info_hlayout.addStretch(0) _hit_map_info_hlayout.addWidget(self._image_info_label) _hit_map_info_hlayout.setSpacing(2) _hit_map_info_hlayout.setContentsMargins(0, 0, 0, 0) _hit_map_tools_hlayout = qt_import.QHBoxLayout( self._hit_map_tools_widget) _hit_map_tools_hlayout.addWidget(_threshold_label) _hit_map_tools_hlayout.addWidget(self._threshold_slider) _hit_map_tools_hlayout.addStretch(0) _hit_map_tools_hlayout.addWidget(self._relaunch_processing_button) _hit_map_tools_hlayout.addWidget(self._create_points_button) _hit_map_tools_hlayout.setSpacing(2) _hit_map_tools_hlayout.setContentsMargins(0, 0, 0, 0) _hit_maps_hlayout = qt_import.QHBoxLayout(hit_maps_widget) _hit_maps_hlayout.addWidget(self._osc_hit_map_plot) _hit_maps_hlayout.addWidget(self._grid_hit_map_plot) _hit_map_gbox_vlayout = qt_import.QVBoxLayout(self._hit_map_gbox) _hit_map_gbox_vlayout.addWidget(hit_maps_widget) _hit_map_gbox_vlayout.addWidget(hit_map_info_widget) _hit_map_gbox_vlayout.addWidget(self._hit_map_tools_widget) _hit_map_gbox_vlayout.setSpacing(2) _hit_map_gbox_vlayout.setContentsMargins(0, 0, 0, 0) """ _summary_gbox_vlayout = qt_import.QVBoxLayout(self._summary_gbox) _summary_gbox_vlayout.addWidget(self._summary_textbrowser) _summary_gbox_vlayout.setSpacing(2) _summary_gbox_vlayout.setContentsMargins(0, 0, 0, 0) _best_postition_gbox_vlayout = qt_import.QVBoxLayout(self._best_pos_gbox) _best_postition_gbox_vlayout.addWidget(self._best_pos_table) _best_postition_gbox_vlayout.setSpacing(2) _best_postition_gbox_vlayout.setContentsMargins(0, 0, 0, 0) """ _main_hlayout = qt_import.QVBoxLayout(self) _main_hlayout.addWidget(self._hit_map_gbox) #_main_hlayout.addWidget(self._summary_gbox) #_main_hlayout.addWidget(self._best_pos_gbox) _main_hlayout.setSpacing(2) _main_hlayout.setContentsMargins(2, 2, 2, 2) # SizePolicies -------------------------------------------------------- # Qt signals and slots ------------------------------------------------ image_display_cbox.stateChanged.connect( self.enable_image_display_state_changed) self._score_type_cbox.activated.connect(self.score_type_changed) self._threshold_slider.valueChanged.connect( self.filter_min_slider_changed) self._relaunch_processing_button.clicked.connect( self.relaunch_processing_clicked) self._create_points_button.clicked.connect(self.create_points_clicked) self._osc_hit_map_plot.mouseMovedSignal.connect(self.mouse_moved) self._osc_hit_map_plot.mouseClickedSignal.connect(self.mouse_clicked) self._osc_hit_map_plot.mouseDoubleClickedSignal.connect( self.move_to_position_clicked) self._osc_hit_map_plot.mouseLeftSignal.connect(self.mouse_left_plot) self._autoscale_button.clicked.connect(self.autoscale_pressed) # Other --------------------------------------------------------------- #self.__tooltip_text = ( # "Double click to move to the position. " + "Right click to open menu." #) #self._osc_hit_map_plot.setToolTip(self.__tooltip_text) self._hit_map_popup_menu.addSeparator() self._hit_map_popup_menu.addAction("Move to position", self.move_to_position_clicked) self._hit_map_popup_menu.addAction("Create centring point", self.create_centring_point_clicked) self._hit_map_popup_menu.addAction("Create helical line", self.create_helical_line_clicked) self._hit_map_popup_menu.addAction( "Rotate 90 degrees and create helical line", self.rotate_and_create_helical_line_clicked, ) self._hit_map_popup_menu.addSeparator() self._hit_map_popup_menu.addAction("Open image in ADXV", self.display_image_clicked) self._hit_map_popup_menu.addSeparator() #self._osc_hit_map_plot.contextMenuEvent = self.open_hit_map_popup_menu if HWR.beamline.online_processing is not None: self.__result_types = HWR.beamline.online_processing.get_result_types( ) for result in self.__result_types: self._score_type_cbox.addItem(result["descr"]) self._score_type_cbox.setMaximumWidth(200) self.__score_key = "spots_resolution" self._relaunch_processing_button.setVisible(False) self._threshold_slider.setRange(0, 100) self._threshold_slider.setTickInterval(5) self._threshold_slider.setFixedWidth(200) self._threshold_slider.setTracking(False) #font = self._best_pos_table.font() #font.setPointSize(8) #self._best_pos_table.setFont(font) """
def __init__(self, *args): BaseWidget.__init__(self, *args) # Hardware objects ---------------------------------------------------- # Internal values ----------------------------------------------------- # Properties ---------------------------------------------------------- self.add_property("label", "string", "") self.add_property("showStop", "boolean", True) self.add_property("defaultStep", "string", "10.0") # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Graphic elements----------------------------------------------------- _main_gbox = qt_import.QGroupBox(self) self.kappa_dspinbox = qt_import.QDoubleSpinBox(_main_gbox) self.kappa_dspinbox.setRange(-360, 360) self.kappaphi_dspinbox = qt_import.QDoubleSpinBox(_main_gbox) self.kappaphi_dspinbox.setRange(-360, 360) self.step_cbox = qt_import.QComboBox(_main_gbox) self.step_button_icon = icons.load_icon("TileCascade2") self.close_button = qt_import.QPushButton(_main_gbox) self.stop_button = qt_import.QPushButton(_main_gbox) # Layout -------------------------------------------------------------- _main_gbox_hlayout = qt_import.QHBoxLayout(_main_gbox) _main_gbox_hlayout.addWidget(qt_import.QLabel("Kappa:", _main_gbox)) _main_gbox_hlayout.addWidget(self.kappa_dspinbox) _main_gbox_hlayout.addWidget(qt_import.QLabel("Phi:", _main_gbox)) _main_gbox_hlayout.addWidget(self.kappaphi_dspinbox) _main_gbox_hlayout.addWidget(self.step_cbox) _main_gbox_hlayout.addWidget(self.close_button) _main_gbox_hlayout.addWidget(self.stop_button) _main_gbox_hlayout.setSpacing(2) _main_gbox_hlayout.setContentsMargins(2, 2, 2, 2) _main_hlayout = qt_import.QHBoxLayout(self) _main_hlayout.addWidget(_main_gbox) _main_hlayout.setSpacing(0) _main_hlayout.setContentsMargins(0, 0, 0, 0) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ kappa_dspinbox_event = SpinBoxEvent(self.kappa_dspinbox) kappaphi_dspinbox_event = SpinBoxEvent(self.kappaphi_dspinbox) self.kappa_dspinbox.installEventFilter(kappa_dspinbox_event) self.kappaphi_dspinbox.installEventFilter(kappaphi_dspinbox_event) kappa_dspinbox_event.returnPressedSignal.connect(self.change_position) kappaphi_dspinbox_event.returnPressedSignal.connect(self.change_position) self.kappa_dspinbox.lineEdit().textEdited.connect(self.kappa_value_edited) self.kappaphi_dspinbox.lineEdit().textEdited.connect(self.kappaphi_value_edited) self.step_cbox.activated.connect(self.go_to_step) self.step_cbox.activated.connect(self.step_changed) self.step_cbox.editTextChanged.connect(self.step_edited) self.close_button.clicked.connect(self.close_clicked) self.stop_button.clicked.connect(self.stop_clicked) # self.stop_button.setSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Minimum) # Other --------------------------------------------------------------- self.kappa_dspinbox.setAlignment(qt_import.Qt.AlignRight) self.kappa_dspinbox.setFixedWidth(75) self.kappaphi_dspinbox.setAlignment(qt_import.Qt.AlignRight) self.kappaphi_dspinbox.setFixedWidth(75) self.step_cbox.setEditable(True) self.step_cbox.setValidator( qt_import.QDoubleValidator(0, 360, 5, self.step_cbox) ) self.step_cbox.setDuplicatesEnabled(False) self.step_cbox.setFixedHeight(27) self.close_button.setIcon(icons.load_icon("Home2")) self.close_button.setFixedSize(27, 27) self.stop_button.setIcon(icons.load_icon("Stop2")) self.stop_button.setEnabled(False) self.stop_button.setFixedSize(27, 27) self.connect(HWR.beamline.diffractometer, "kappaMotorMoved", self.kappa_motor_moved) self.connect(HWR.beamline.diffractometer, "kappaPhiMotorMoved", self.kappaphi_motor_moved) self.connect(HWR.beamline.diffractometer, "minidiffStatusChanged", self.diffractometer_state_changed)
def __init__(self, parent=None, name=None, fl=0): qt_import.QWidget.__init__(self, parent, qt_import.Qt.WindowFlags(fl)) if not name: self.setObjectName("VerticalCrystalDimensionWidgetLayout") return VerticalCrystalDimensionWidgetLayoutLayout = qt_import.QVBoxLayout( self, 0, 6, "VerticalCrystalDimensionWidgetLayoutLayout") self.gbox = qt_import.QGroupBox(self, "gbox") self.gbox.setSizePolicy(qt_import.QSizePolicy.MinimumExpanding, qt_import.QSizePolicy.MinimumExpanding) self.gbox.setChecked(0) self.gbox.setColumnLayout(0, qt_import.Qt.Vertical) self.gbox.layout().setSpacing(6) self.gbox.layout().setMargin(11) gboxLayout = qt_import.QHBoxLayout(self.gbox.layout()) gboxLayout.setAlignment(qt_import.Qt.AlignTop) main_layout = qt_import.QVBoxLayout(None, 0, 15, "main_layout") space_group_layout = qt_import.QHBoxLayout(None, 0, 6, "space_group_layout") space_group_ledit_layout = qt_import.QHBoxLayout( None, 0, 6, "space_group_ledit_layout") self.space_group_label = qt_import.QLabel(self.gbox, "space_group_label") space_group_ledit_layout.addWidget(self.space_group_label) self.space_group_ledit = qt_import.QComboBox(0, self.gbox, "space_group_ledit") self.space_group_ledit.setMinimumSize(qt_import.QSize(100, 0)) self.space_group_ledit.setMaximumSize(qt_import.QSize(100, 32767)) space_group_ledit_layout.addWidget(self.space_group_ledit) space_group_layout.addLayout(space_group_ledit_layout) space_group_hspacer = qt_import.QSpacerItem( 1, 20, qt_import.QSizePolicy.Expanding, qt_import.QSizePolicy.Minimum) space_group_layout.addItem(space_group_hspacer) main_layout.addLayout(space_group_layout) vdim_layout = qt_import.QVBoxLayout(None, 0, 2, "vdim_layout") vdim_heading_layout = qt_import.QHBoxLayout(None, 0, 6, "vdim_heading_layout") self.dimension_label = qt_import.QLabel(self.gbox, "dimension_label") vdim_heading_layout.addWidget(self.dimension_label) vdim_heading_spacer = qt_import.QSpacerItem( 1, 20, qt_import.QSizePolicy.Expanding, qt_import.QSizePolicy.Minimum) vdim_heading_layout.addItem(vdim_heading_spacer) vdim_layout.addLayout(vdim_heading_layout) vdim_control_layout = qt_import.QHBoxLayout(None, 0, 0, "vdim_control_layout") vdim_ledit_hlayout = qt_import.QHBoxLayout(None, 0, 20, "vdim_ledit_hlayout") col_one_vdim_ledit_hlayout = qt_import.QHBoxLayout( None, 0, 6, "col_one_vdim_ledit_hlayout") vlayout_min_vdim_label = qt_import.QVBoxLayout( None, 0, 6, "vlayout_min_vdim_label") self.min_vdim_label = qt_import.QLabel(self.gbox, "min_vdim_label") vlayout_min_vdim_label.addWidget(self.min_vdim_label) self.vdim_min_phi_label = qt_import.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 = qt_import.QVBoxLayout( None, 0, 6, "vlayout_min_vdim_ledit") self.min_vdim_ledit = qt_import.QLineEdit(self.gbox, "min_vdim_ledit") self.min_vdim_ledit.setMinimumSize(qt_import.QSize(50, 0)) self.min_vdim_ledit.setMaximumSize(qt_import.QSize(50, 32767)) vlayout_min_vdim_ledit.addWidget(self.min_vdim_ledit) self.min_vphi_ledit = qt_import.QLineEdit(self.gbox, "min_vphi_ledit") self.min_vphi_ledit.setMinimumSize(qt_import.QSize(50, 0)) self.min_vphi_ledit.setMaximumSize(qt_import.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 = qt_import.QHBoxLayout( None, 0, 6, "col_two_vdim_ledit_hlayout") vlayout_two_vdim_hlayout = qt_import.QVBoxLayout( None, 0, 6, "vlayout_two_vdim_hlayout") self.max_vdim_label = qt_import.QLabel(self.gbox, "max_vdim_label") vlayout_two_vdim_hlayout.addWidget(self.max_vdim_label) self.max_vphi_label = qt_import.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 = qt_import.QVBoxLayout( None, 0, 6, "vlayout_max_vdim_ledit") self.max_vdim_ledit = qt_import.QLineEdit(self.gbox, "max_vdim_ledit") self.max_vdim_ledit.setMinimumSize(qt_import.QSize(50, 0)) self.max_vdim_ledit.setMaximumSize(qt_import.QSize(50, 32767)) vlayout_max_vdim_ledit.addWidget(self.max_vdim_ledit) self.max_vphi_ledit = qt_import.QLineEdit(self.gbox, "max_vphi_ledit") self.max_vphi_ledit.setMinimumSize(qt_import.QSize(50, 0)) self.max_vphi_ledit.setMaximumSize(qt_import.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 = qt_import.QSpacerItem(1, 20, qt_import.QSizePolicy.Expanding, qt_import.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( qt_import.QSize(307, 163).expandedTo(self.minimumSizeHint()))
def __init__(self, *args): BaseWidget.__init__(self, *args) # Hardware objects ---------------------------------------------------- self.crl_hwobj = None # Internal values ----------------------------------------------------- self.crl_value = [] # Properties ---------------------------------------------------------- self.add_property("lenseCount", "integer", 6) self.add_property("mnemonic", "string", "") self.add_property("formatString", "formatString", "#.#") self.add_property("caption", "string", "") self.add_property( "style", "combo", ("table", "number"), "table" ) # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Graphic elements ---------------------------------------------------- self.main_gbox = qt_import.QGroupBox("CRL", self) self.mode_combo = qt_import.QComboBox(self.main_gbox) self.set_according_to_energy_button = qt_import.QPushButton( "Set", self.main_gbox) self.set_out_button = qt_import.QPushButton("Out", self.main_gbox) # self.align_beam_button = qt_import.QtGui.QPushButton("Align", self.main_gbox) self.crl_widget = qt_import.QWidget(self.main_gbox) self.crl_value_table = qt_import.QTableWidget(self.crl_widget) self.crl_lense_spinbox = qt_import.QSpinBox(self.crl_widget) self.crl_lense_in_button = qt_import.QPushButton("In", self.crl_widget) self.crl_lense_out_button = qt_import.QPushButton("Out", self.crl_widget) self.move_up_button = qt_import.QPushButton("", self.main_gbox) self.move_down_button = qt_import.QPushButton("", self.main_gbox) # Layout -------------------------------------------------------------- _crl_widget_hlayout = qt_import.QHBoxLayout(self.crl_widget) _crl_widget_hlayout.addWidget(self.crl_value_table) _crl_widget_hlayout.addWidget(self.crl_lense_spinbox) _crl_widget_hlayout.addWidget(self.crl_lense_in_button) _crl_widget_hlayout.addWidget(self.crl_lense_out_button) _crl_widget_hlayout.setSpacing(2) _crl_widget_hlayout.setContentsMargins(0, 0, 0, 0) _main_gbox_gridlayout = qt_import.QGridLayout(self.main_gbox) _main_gbox_gridlayout.addWidget(self.mode_combo, 0, 0) _main_gbox_gridlayout.addWidget(self.set_according_to_energy_button, 0, 1) _main_gbox_gridlayout.addWidget(self.set_out_button, 1, 1) _main_gbox_gridlayout.addWidget(self.crl_widget, 1, 0) # _main_gbox_gridlayout.addWidget(self.align_beam_button, 1, 1) _main_gbox_gridlayout.addWidget(self.move_up_button, 0, 2) _main_gbox_gridlayout.addWidget(self.move_down_button, 1, 2) _main_gbox_gridlayout.setSpacing(2) _main_gbox_gridlayout.setContentsMargins(2, 2, 2, 2) _main_vlayout = qt_import.QVBoxLayout(self) _main_vlayout.addWidget(self.main_gbox) _main_vlayout.setSpacing(0) _main_vlayout.setContentsMargins(2, 2, 2, 2) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ self.mode_combo.activated.connect(self.set_crl_mode) self.crl_value_table.itemDoubleClicked.connect( self.crl_table_item_doubleclicked ) self.set_according_to_energy_button.clicked.connect( self.set_according_to_energy ) self.set_out_button.clicked.connect(self.set_out_clicked) self.move_up_button.clicked.connect(self.move_up_clicked) self.move_down_button.clicked.connect(self.move_down_clicked) # Other --------------------------------------------------------------- self.mode_combo.setCurrentIndex(1) self.crl_value_table.setRowCount(1) self.crl_value_table.verticalHeader().hide() self.crl_value_table.horizontalHeader().hide() self.crl_value_table.setRowHeight(0, 20) self.crl_value_table.setFixedHeight(24) self.crl_value_table.setShowGrid(True) # self.set_according_to_energy_button.setIcon(icons.load_icon("Up2")) # self.set_out_button.setIcon(icons.load_icon("Up2")) self.move_up_button.setIcon(icons.load_icon("Up2")) self.move_up_button.setFixedWidth(25) self.move_down_button.setIcon(icons.load_icon("Down2")) self.move_down_button.setFixedWidth(25) self.set_according_to_energy_button.setFixedWidth(30) self.set_out_button.setFixedWidth(30) self.crl_lense_in_button.setFixedWidth(30) self.crl_lense_out_button.setFixedWidth(30)
def init_view(self): self.chan_config = HWR.beamline.ssx_setup.get_config() self.chan_table.blockSignals(True) self.chan_table.setColumnCount(3) for index, header_text in enumerate(("Name", "Delay", "Length")): self.chan_table.setHorizontalHeaderItem( index, qt_import.QTableWidgetItem(header_text)) if index > 0: self.chan_table.resizeColumnToContents(index) self.chan_table.setRowCount(self.chan_config["num_channels"]) self.chan_seq = [None] * self.chan_config["num_channels"] self.chan_table.verticalHeader().setDefaultSectionSize(20) self.chan_table.setFixedHeight(20 * (self.chan_config["num_channels"] + 2) + 10) for index in range(self.chan_config["num_channels"]): combo = qt_import.QComboBox() combo.activated.connect(self.chan_seq_combo_activated) for chan_name in self.chan_config["channels"].keys(): combo.addItem(chan_name) combo.addItem("") combo.setCurrentIndex(-1) self.chan_table.setCellWidget(index, 0, combo) self.chan_combo_items.append(combo) for col in (1, 2): self.chan_table.setItem(index, col, qt_import.QTableWidgetItem("")) if index < len(self.chan_config["default_seq"]): def_chan_item_name = self.chan_config["default_seq"][index] combo.setCurrentIndex(combo.findText(def_chan_item_name)) self.chan_table.setItem( index, 1, qt_import.QTableWidgetItem( str(self.chan_config["channels"][def_chan_item_name] [0]))) self.chan_table.setItem( index, 2, qt_import.QTableWidgetItem( str(self.chan_config["channels"][def_chan_item_name] [1]))) self.chan_table.blockSignals(False) self.refresh_chan_sequence() self.metadata_dict = HWR.beamline.ssx_setup.get_metadata_dict() for index, key in enumerate(self.metadata_dict.keys()): row = index // 2 value = self.metadata_dict[key] metadata_title_ledit = qt_import.QLabel(value["descr"] + ": ") self.metadata_gbox_glayout.addWidget(metadata_title_ledit, row, index % 2 * 2) metadata_value_ledit = qt_import.QLineEdit(str(value["value"])) metadata_value_ledit.setObjectName(key) if value.get("limits"): limits = value.get("limits") metadata_value_ledit.setValidator( qt_import.QDoubleValidator(limits[0], limits[1], 2, metadata_value_ledit)) tooltip = "%s limits: %s - %s" % (value["descr"], str( limits[0]), str(limits[1])) metadata_value_ledit.setToolTip(tooltip) metadata_value_ledit.textChanged.connect( self.metadata_value_changed) self.metadata_gbox_glayout.addWidget(metadata_value_ledit, row, index % 2 * 2 + 1) metadata_title_ledit.setDisabled(value.get("read_only", False)) metadata_value_ledit.setDisabled(value.get("read_only", False))
def __init__(self, *args): """ Proposal brick is used to authentificate current user. Brick can be used in two modes defined by ispyb hwobj - loginAsUser = True, Brick displays combobox with all proposals from ISPyB that are associated to the current user - loginAsUser = False. Brick displays combobox to choose proposal type and linedits to enter proposal number and password. In this case user is authentificated with LDAP and proposal from ISPyB is retrieved. """ BaseWidget.__init__(self, *args) # Hardware objects ---------------------------------------------------- self.local_login_hwobj = None # Internal values ----------------------------------------------------- self.login_as_user = None self.proposal = None self.person = None self.laboratory = None # self.sessionId=None self.inhouseProposal = None self.instance_server_hwobj = None self.secondary_proposals = [] # Properties ---------------------------------------------------------- self.add_property("titlePrefix", "string", "") self.add_property("autoSessionUsers", "string", "") self.add_property("codes", "string", "fx ifx ih im ix ls mx opid") self.add_property("secondaryProposals", "string", "") self.add_property("icons", "string", "") self.add_property("serverStartDelay", "integer", 500) # Signals ------------------------------------------------------------ self.define_signal("sessionSelected", ()) self.define_signal("setWindowTitle", ()) self.define_signal("loggedIn", ()) self.define_signal("userGroupSaved", ()) # Slots --------------------------------------------------------------- self.define_slot("setButtonEnabled", ()) self.define_slot("impersonateProposal", ()) # Graphic elements ---------------------------------------------------- self.main_gbox = qt_import.QGroupBox("ISPyB proposal", self) self.login_as_proposal_widget = qt_import.QWidget(self.main_gbox) code_label = qt_import.QLabel(" Code: ", self.login_as_proposal_widget) self.proposal_type_combox = qt_import.QComboBox(self.login_as_proposal_widget) self.proposal_type_combox.setEditable(True) self.proposal_type_combox.setFixedWidth(60) dash_label = qt_import.QLabel(" - ", self.login_as_proposal_widget) self.proposal_number_ledit = qt_import.QLineEdit(self.login_as_proposal_widget) self.proposal_number_ledit.setFixedWidth(60) password_label = qt_import.QLabel(" Password: "******"Login", self.login_as_proposal_widget) self.login_button.setFixedWidth(70) self.logout_button = qt_import.QPushButton("Logout", self.main_gbox) self.logout_button.hide() self.logout_button.setFixedWidth(70) self.login_as_proposal_widget.hide() self.login_as_user_widget = qt_import.QWidget(self.main_gbox) self.proposal_combo = qt_import.QComboBox(self.login_as_user_widget) self.user_group_widget = qt_import.QWidget(self.main_gbox) # self.title_label = QtGui.QLabel(self.user_group_widget) # self.title_label.setAlignment(QtCore.Qt.AlignCenter) self.user_group_label = qt_import.QLabel(" Group: ", self.user_group_widget) self.user_group_ledit = qt_import.QLineEdit(self.user_group_widget) self.user_group_ledit.setFixedSize(100, 27) self.user_group_save_button = qt_import.QToolButton(self.user_group_widget) self.user_group_save_button.setText("Set") self.user_group_save_button.setFixedHeight(27) self.saved_group = True # Layout -------------------------------------------------------------- _user_group_widget_hlayout = qt_import.QHBoxLayout(self.user_group_widget) _user_group_widget_hlayout.setSpacing(2) # _user_group_widget_hlayout.addWidget(self.title_label) _user_group_widget_hlayout.addWidget(self.user_group_label) _user_group_widget_hlayout.addWidget(self.user_group_ledit) _user_group_widget_hlayout.addWidget(self.user_group_save_button) _user_group_widget_hlayout.setContentsMargins(0, 0, 0, 0) self.user_group_widget.hide() _login_as_proposal_widget_layout = qt_import.QHBoxLayout( self.login_as_proposal_widget ) _login_as_proposal_widget_layout.addWidget(code_label) _login_as_proposal_widget_layout.addWidget(self.proposal_type_combox) _login_as_proposal_widget_layout.addWidget(dash_label) _login_as_proposal_widget_layout.addWidget(self.proposal_number_ledit) _login_as_proposal_widget_layout.addWidget(password_label) _login_as_proposal_widget_layout.addWidget(self.proposal_password_ledit) _login_as_proposal_widget_layout.addWidget(self.login_button) _login_as_proposal_widget_layout.setSpacing(2) _login_as_proposal_widget_layout.setContentsMargins(0, 0, 0, 0) _login_as_user_widget_layout = qt_import.QHBoxLayout(self.login_as_user_widget) _login_as_user_widget_layout.addWidget(self.proposal_combo) _login_as_user_widget_layout.setSpacing(2) _login_as_user_widget_layout.setContentsMargins(0, 0, 0, 0) _main_gboxlayout = qt_import.QHBoxLayout(self.main_gbox) _main_gboxlayout.addWidget(self.login_as_proposal_widget) _main_gboxlayout.addWidget(self.logout_button) _main_gboxlayout.addWidget(self.login_as_user_widget) _main_gboxlayout.addStretch() _main_gboxlayout.addWidget(self.user_group_widget) _main_gboxlayout.setSpacing(2) _main_gboxlayout.setContentsMargins(0, 0, 0, 0) _main_vlayout = qt_import.QVBoxLayout(self) _main_vlayout.addWidget(self.main_gbox) _main_vlayout.setSpacing(2) _main_vlayout.setContentsMargins(2, 2, 2, 2) # SizePolicies -------------------------------------------------------- # self.user_group_ledit # Qt signal/slot connections ------------------------------------------ self.proposal_password_ledit.returnPressed.connect(self.login) self.login_button.clicked.connect(self.login) self.logout_button.clicked.connect(self.logout_clicked) self.proposal_combo.activated.connect(self.proposal_combo_activated) self.user_group_save_button.clicked.connect(self.save_group) self.user_group_ledit.returnPressed.connect(self.save_group) self.user_group_ledit.textChanged.connect(self.user_group_changed) # Other --------------------------------------------------------------- colors.set_widget_color( self.proposal_number_ledit, colors.LIGHT_RED, qt_import.QPalette.Base ) colors.set_widget_color( self.proposal_password_ledit, colors.LIGHT_RED, qt_import.QPalette.Base )