def update(self, state=None): """ Descript. : Args. : Return. : """ if self.actuator_hwo is not None: if state is None: state = self.actuator_hwo.getState() status = self.actuator_hwo.getStatus() self.widget.stateLabel.setText(status) Qt4_widget_colors.set_widget_color(self.widget.stateLabel, STATES[state]) self.widget.cmdInButton.setEnabled(False) self.widget.cmdOutButton.setEnabled(False) self.widget.cmdInButton.setChecked(False) self.widget.cmdOutButton.setChecked(False) if state == STATE_IN: self.widget.cmdOutButton.setEnabled(True) self.widget.cmdInButton.setChecked(True) elif state == STATE_OUT: self.widget.cmdInButton.setEnabled(True) self.widget.cmdOutButton.setChecked(True) self.state = state
def centring_successful(self, method, centring_status): """ Descript. : Args. : Return : """ self.button_centre.command_done() if self.current_centring is not None: self.current_centring = None self.button_accept.setEnabled(True) self.button_reject.setEnabled(True) if self.inside_data_collection: Qt4_widget_colors.set_widget_color(self.button_accept, Qt4_widget_colors.LIGHT_GREEN) Qt4_widget_colors.set_widget_color(self.button_reject, Qt4_widget_colors.LIGHT_RED) if self.collect_hwobj is not None: self.collect_hwobj.setCentringStatus(centring_status) self.graphics_manager_hwobj.set_centring_state(False) self.is_moving = False self.main_frame.setEnabled(True) self.emit(QtCore.SIGNAL("enableMinidiff"), (True,)) try: successful_method = self.successful_methods[method] except KeyError, diag: pass
def detector_distance_state_changed(self, state): if state is None: #Fix this TODO return color = Qt4_ResolutionBrick.STATE_COLORS[state] unit = self.units_combobox.currentText() # LNLS #if unit == "mm": if state == self.detector_distance_hwobj.READY: self.new_value_ledit.blockSignals(True) self.new_value_ledit.setText("") self.new_value_ledit.blockSignals(False) self.new_value_ledit.setEnabled(True) else: self.new_value_ledit.setEnabled(False) if state == self.detector_distance_hwobj.MOVING or \ state == self.detector_distance_hwobj.MOVESTARTED: self.stop_button.setEnabled(True) else: self.stop_button.setEnabled(False) # LNLS #Qt4_widget_colors.set_widget_color(self.new_value_ledit, color) Qt4_widget_colors.set_widget_color(self.detector_distance_ledit, color, QtGui.QPalette.Base) if state == self.detector_distance_hwobj.READY: if self.original_background_color is None: self.original_background_color = Qt4_widget_colors.LINE_EDIT_ORIGINAL color = self.original_background_color
def propertyChanged(self, property_name, old_value, new_value): if property_name == 'label': if new_value == "" and self.motor_hwobj is not None: self.label.setText("<i>" + self.motor_hwobj.username + ":</i>") else: self.label.setText(new_value) elif property_name == 'mnemonic': if self.motor_hwobj is not None: self.disconnect(self.motor_hwobj, 'stateChanged', self.motor_state_changed) self.disconnect(self.motor_hwobj, 'newPredefinedPositions', self.fill_positions) self.disconnect(self.motor_hwobj, 'predefinedPositionChanged', self.predefined_position_changed) self.motor_hwobj = self.getHardwareObject(new_value) if self.motor_hwobj is not None: self.connect(self.motor_hwobj, 'newPredefinedPositions', self.fill_positions) self.connect(self.motor_hwobj, 'stateChanged', self.motor_state_changed) self.connect(self.motor_hwobj, 'predefinedPositionChanged', self.predefined_position_changed) self.fill_positions() if self.motor_hwobj.is_ready(): if hasattr(self.motor_hwobj, "getCurrentPositionName"): self.predefined_position_changed( self.motor_hwobj.getCurrentPositionName(), 0) else: self.predefined_position_changed( self.motor_hwobj.get_current_position_name(), 0) if self['label'] == "": lbl = self.motor_hwobj.username self.label.setText("<i>" + lbl + ":</i>") Qt4_widget_colors.set_widget_color( self.positions_combo, Qt4_MotorPredefPosBrick.STATE_COLORS[0], QPalette.Button) #TODO remove this check if hasattr(self.motor_hwobj, "getState"): self.motor_state_changed(self.motor_hwobj.getState()) else: self.motor_state_changed(self.motor_hwobj.get_state()) elif property_name == 'showMoveButtons': if new_value: self.previous_position_button.show() self.next_position_button.show() else: self.previous_position_button.hide() self.next_position_button.hide() elif property_name == 'icons': icons_list = new_value.split() try: self.previous_position_button.setIcon(\ Qt4_Icons.load_icon(icons_list[0])) self.next_position_button.setIcon(\ Qt4_Icons.load_icon(icons_list[1])) except: pass else: BlissWidget.propertyChanged(self, property_name, old_value, new_value)
def queue_paused_handler(self, state): print("----------------------------------------------------") print("Qt4_dc_tree_wid - queue_paused_handler") print("state: ", state) print("----------------------------------------------------") """ Descript. : """ if state: self.parent().enable_hutch_menu(True) self.parent().enable_command_menu(True) self.parent().enable_task_toolbox(True) self.continue_button.setText('Continue') print("Qt4_widget_colors.LIGHT_YELLOW: ", Qt4_widget_colors.LIGHT_YELLOW) Qt4_widget_colors.set_widget_color(self.continue_button, Qt4_widget_colors.LIGHT_YELLOW, QtGui.QPalette.Button) else: self.parent().enable_hutch_menu(False) self.parent().enable_command_menu(False) self.parent().enable_task_toolbox(False) self.continue_button.setText('Pause') print("Qt4_widget_colors.BUTTON_ORIGINAL: ", Qt4_widget_colors.BUTTON_ORIGINAL) Qt4_widget_colors.set_widget_color( self.continue_button, Qt4_widget_colors.BUTTON_ORIGINAL, QtGui.QPalette.Button)
def resolution_state_changed(self, state): if self.detector_distance_hwobj is not None: if state: color = Qt4_ResolutionBrick.STATE_COLORS[state] else: color = Qt4_widget_colors.LIGHT_RED unit = self.units_combobox.currentText() # LNLS #if unit == chr(197): if state == self.detector_distance_hwobj.READY: self.new_value_ledit.blockSignals(True) self.new_value_ledit.setText("") self.new_value_ledit.blockSignals(False) self.new_value_ledit.setEnabled(True) else: self.new_value_ledit.setEnabled(False) if state == self.detector_distance_hwobj.MOVING or \ state == self.detector_distance_hwobj.MOVESTARTED: self.stop_button.setEnabled(True) else: self.stop_button.setEnabled(False) # LNLS #Qt4_widget_colors.set_widget_color(self.new_value_ledit, color) Qt4_widget_colors.set_widget_color(self.resolution_ledit, color, QtGui.QPalette.Base) #replace with isReady if state == self.detector_distance_hwobj.READY: if self.original_background_color is None: #self.original_background_color = self.paletteBackgroundColor() self.original_background_color = Qt4_widget_colors.LINE_EDIT_ORIGINAL color = self.original_background_color """
def motor_state_changed(self, state): s = state in (self.motor_hwobj.READY, self.motor_hwobj.ONLIMIT) self.positions_combo.setEnabled(s) Qt4_widget_colors.set_widget_color( self.positions_combo, Qt4_MotorPredefPosBrick.STATE_COLORS[state], QPalette.Button) self.setToolTip(state=state)
def __init__(self, parent, realtime_plot = False): """ Descript. : """ QWidget.__init__(self, parent) self.axis_x_array = [] self.axis_y_array = [] self.realtime_plot = realtime_plot self.pymca_graph = Graph(self) self.pymca_graph.showGrid() self.info_label = QLabel("", self) self.info_label.setAlignment(Qt.AlignRight) _main_vlayout = 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(QSizePolicy.Expanding, QSizePolicy.Expanding) if qt_variant == 'PyQt5': pass else: QObject.connect(self.pymca_graph, SIGNAL("QtBlissGraphSignal"), self.handle_graph_signal) Qt4_widget_colors.set_widget_color(self, Qt4_widget_colors.WHITE)
def collect_items(self, items=[], checked_items=[]): """ Descript. : """ self.beamline_setup_hwobj.shape_history_hwobj.de_select_all() for item in checked_items: # update the run-number text incase of re-collect #item.setText(0, item.get_model().get_name()) #Clear status item.setText(1, "") item.reset_style() self.user_stopped = False self.delete_button.setEnabled(False) self.enable_sample_changer_widget(False) self.collecting = True self.collect_button.setText(" Stop ") Qt4_widget_colors.set_widget_color(self.collect_button, Qt4_widget_colors.LIGHT_RED, QtGui.QPalette.Button) self.collect_button.setIcon(self.stop_icon) self.continue_button.setEnabled(True) self.parent().enable_hutch_menu(False) self.run_cb() QtGui.QApplication.setOverrideCursor( QtGui.QCursor(QtCore.Qt.BusyCursor)) try: self.queue_hwobj.execute() except Exception as e: raise e
def resolution_state_changed(self, state): logging.getLogger("HWR").debug('Qt4_ResolutionBrick: resolution_state_changed called state %s type %s' % (state, type(state)) ) if self.detector_distance_hwobj is not None: if state: color = Qt4_ResolutionBrick.STATE_COLORS[state] else: color = Qt4_widget_colors.LIGHT_RED unit = self.units_combobox.currentText() if unit is chr(197): if state == self.detector_distance_hwobj.motor_states.READY: self.new_value_ledit.blockSignals(True) self.new_value_ledit.setText("") self.new_value_ledit.blockSignals(False) self.new_value_ledit.setEnabled(True) else: self.stop_button.setEnabled(True) else: self.stop_button.setEnabled(True) #if state == self.detector_distance_hwobj.motor_states.MOVING or state == self.detector_distance_hwobj.motor_states.MOVESTARTED: #self.stop_button.setEnabled(True) #else: #self.stop_button.setEnabled(False) Qt4_widget_colors.set_widget_color(self.new_value_ledit, color)
def centring_failed(self, method, centring_status): """ Descript. : Args. : Return : """ self.clickedPoints = [] self.button_centre.command_failed() if self.current_centring is not None: # self.current_centring.setPaletteBackgroundColor(self.defaultBackgroundColor) self.current_centring = None self.graphics_manager_hwobj.set_centring_state(False) self.button_accept.setEnabled(False) if self.inside_data_collection: Qt4_widget_colors.set_widget_color(self.button_accept, self.button_standart_color) self.button_reject.setEnabled(True) Qt4_widget_colors.set_widget_color(self.button_reject, QtCore.Qt.red) else: self.button_reject.setEnabled(False) if self.collect_hwobj is not None: self.collect_hwobj.setCentringStatus(centring_status) self.emit(QtCore.SIGNAL("enableMinidiff"), (True, )) try: reset_method = self.reset_methods[method] except KeyError, diag: pass
def __init__(self, parent=None, name=None, fl=0): QtGui.QWidget.__init__(self, parent, QtCore.Qt.WindowFlags(fl)) if not name: self.setObjectName("RadiationDamageModelWidgetLayout") # Hardware objects ---------------------------------------------------- # Internal variables -------------------------------------------------- # Graphic elements ---------------------------------------------------- self.rad_damage_widget = uic.loadUi( os.path.join( os.path.dirname(__file__), "ui_files/Qt4_radiation_damage_model_widget_layout.ui")) # Layout -------------------------------------------------------------- _main_vlayout = QtGui.QVBoxLayout(self) _main_vlayout.addWidget(self.rad_damage_widget) _main_vlayout.setSpacing(0) _main_vlayout.setContentsMargins(0, 0, 0, 0) self.setLayout(_main_vlayout) # Size policies ------------------------------------------------------- # Other --------------------------------------------------------------- self.languageChange() self.setAttribute(QtCore.Qt.WA_WState_Polished) Qt4_widget_colors.set_widget_color(self, Qt4_widget_colors.GROUP_BOX_GRAY)
def propertyChanged(self,propertyName,oldValue,newValue): if propertyName=='label': if newValue=="" and self.motor_hwobj is not None: self.label.setText("<i>"+self.motor_hwobj.username+":</i>") tip=self.motor_hwobj.username else: self.label.setText(newValue) tip=newValue elif propertyName=='mnemonic': if self.motor_hwobj is not None: self.disconnect(self.motor_hwobj, QtCore.SIGNAL('stateChanged'), self.motorStateChanged) self.disconnect(self.motor_hwobj, QtCore.SIGNAL('newPredefinedPositions'), self.fillPositions) self.disconnect(self.motor_hwobj, QtCore.SIGNAL('predefinedPositionChanged'), self.predefinedPositionChanged) self.motor_hwobj = self.getHardwareObject(newValue) if self.motor_hwobj is not None: self.connect(self.motor_hwobj, QtCore.SIGNAL('newPredefinedPositions'), self.fillPositions) self.connect(self.motor_hwobj, QtCore.SIGNAL('stateChanged'), self.motorStateChanged) self.connect(self.motor_hwobj, QtCore.SIGNAL('predefinedPositionChanged'), self.predefinedPositionChanged) self.fillPositions() if self.motor_hwobj.isReady(): self.predefinedPositionChanged(self.motor_hwobj.getCurrentPositionName(), 0) if self['label']=="": lbl=self.motor_hwobj.username self.label.setText("<i>"+lbl+":</i>") Qt4_widget_colors.set_widget_color(self.positions_combo, Qt4_MotorPredefPosBrick.STATE_COLORS[0], QtGui.QPalette.Button) self.motorStateChanged(self.motor_hwobj.getState()) elif propertyName=='listIndex': self.fillPositions() else: BlissWidget.propertyChanged(self,propertyName,oldValue,newValue)
def centring_failed(self, method, centring_status): """ Descript. : Args. : Return : """ self.clickedPoints = [] self.button_centre.command_failed() if self.current_centring is not None: # self.current_centring.setPaletteBackgroundColor(self.defaultBackgroundColor) self.current_centring = None self.graphics_manager_hwobj.set_centring_state(False) self.button_accept.setEnabled(False) if self.inside_data_collection: Qt4_widget_colors.set_widget_color(self.button_accept, self.button_standart_color) self.button_reject.setEnabled(True) Qt4_widget_colors.set_widget_color(self.button_reject, QtCore.Qt.red) else: self.button_reject.setEnabled(False) if self.collect_hwobj is not None: self.collect_hwobj.setCentringStatus(centring_status) self.emit(QtCore.SIGNAL("enableMinidiff"), (True,)) try: reset_method = self.reset_methods[method] except KeyError, diag: pass
def set_color(self, color): """ Descript. : """ if not color: self.qtcolor = None self.color = None Qt4_widget_colors.set_widget_color(\ self.change_color_button, Qt4_widget_colors.BUTTON_ORIGINAL, QPalette.Button) else: try: rgb = color.rgb() except: try: self.qtcolor = QColor(color) except: self.qtcolor = QtColor(Qt.green) self.color = self.qtcolor.rgb() else: self.color = self.qtcolor.rgb() else: self.qtcolor = color self.color = rgb Qt4_widget_colors.set_widget_color(self.change_color_button, self.qtcolor, QPalette.Button) self.parent.cellChanged.emit(self.row, self.col)
def put_back_colors(wref=weakref.ref(widget), bkgd_color=original_color): widget = wref() if widget is not None: Qt4_widget_colors.set_widget_color(widget, bkgd_color, QtGui.QPalette.Background)
def _folder_ledit_change(self, new_value): """ Descript. : """ base_image_dir = self._base_image_dir base_proc_dir = self._base_process_dir new_sub_dir = str(new_value).strip(' ') if len(new_sub_dir) > 0: if new_sub_dir[0] == os.path.sep: new_sub_dir = new_sub_dir[1:] new_image_directory = os.path.join(base_image_dir, str(new_sub_dir)) new_proc_dir = os.path.join(base_proc_dir, str(new_sub_dir)) else: new_image_directory = base_image_dir new_proc_dir = base_proc_dir self._data_model.directory = new_image_directory self._data_model.process_directory = new_proc_dir Qt4_widget_colors.set_widget_color(self.data_path_layout.folder_ledit, Qt4_widget_colors.WHITE) self.emit(QtCore.SIGNAL('pathTemplateChanged'), self.data_path_layout.folder_ledit, new_value)
def temperature_changed(self, value, status_ok): unit = u"\N{DEGREE SIGN}" self.temperature_label.setText(" Temperature : %0.1f%s" % (value, unit)) if status_ok: Qt4_widget_colors.set_widget_color(self.temperature_label, Qt4_DetectorStatusBrick.STATES["OK"]) else: Qt4_widget_colors.set_widget_color(self.temperature_label, Qt4_DetectorStatusBrick.STATES["BAD"])
def _folder_ledit_change(self, new_value): """ Descript. : """ base_image_dir = self._base_image_dir base_proc_dir = self._base_process_dir new_sub_dir = str(new_value).strip(' ') cursor_pos = self.data_path_layout.folder_ledit.cursorPosition() if len(new_value) > 0: available_chars = string.ascii_lowercase + string.ascii_uppercase + \ string.digits + "-_/" if self.enable_macros: available_chars += "%" new_value = ''.join(i for i in str(new_value) if i in available_chars) self.data_path_layout.folder_ledit.setText(new_value) self.data_path_layout.folder_ledit.setCursorPosition(cursor_pos) if len(new_sub_dir) > 0: if new_sub_dir[0] == os.path.sep: new_sub_dir = new_sub_dir[1:] new_image_directory = os.path.join(base_image_dir, str(new_sub_dir)) new_proc_dir = os.path.join(base_proc_dir, str(new_sub_dir)) else: new_image_directory = base_image_dir new_proc_dir = base_proc_dir self._data_model.directory = new_image_directory self._data_model.process_directory = new_proc_dir Qt4_widget_colors.set_widget_color(self.data_path_layout.folder_ledit, Qt4_widget_colors.WHITE) self.pathTemplateChangedSignal.emit()
def set_selected(self, state): if state is True: Qt4_widget_colors.set_widget_color(self, \ Qt4_widget_colors.LIGHT_GREEN) else: Qt4_widget_colors.set_widget_color(self, \ Qt4_widget_colors.BUTTON_ORIGINAL)
def __init__(self,parent = None,name = None,fl = 0): QtGui.QWidget.__init__(self, parent, QtCore.Qt.WindowFlags(fl)) if not name: self.setObjectName("OptimisationParametersWidgetLayout") # Hardware objects ---------------------------------------------------- # Internal variables -------------------------------------------------- # Graphic elements ---------------------------------------------------- self.opt_param_widget = uic.loadUi(os.path.join(os.path.dirname(__file__), "ui_files/Qt4_optimization_parameters_widget_layout.ui")) # Layout -------------------------------------------------------------- _main_vlayout = QtGui.QVBoxLayout(self) _main_vlayout.addWidget(self.opt_param_widget) _main_vlayout.setSpacing(0) _main_vlayout.setContentsMargins(0, 0, 0, 0) self.setLayout(_main_vlayout) # Size policies ------------------------------------------------------- # Other --------------------------------------------------------------- self.languageChange() #self.resize(QtCore.QSize(603,190).expandedTo(self.minimumSizeHint())) self.setAttribute(QtCore.Qt.WA_WState_Polished) Qt4_widget_colors.set_widget_color(self, Qt4_widget_colors.GROUP_BOX_GRAY)
def __init__(self, parent = None, name = None, fl = 0): QtGui.QWidget.__init__(self, parent, QtCore.Qt.WindowFlags(fl)) if not name: self.setObjectName("RadiationDamageModelWidgetLayout") # Hardware objects ---------------------------------------------------- # Internal variables -------------------------------------------------- # Graphic elements ---------------------------------------------------- self.rad_damage_widget = uic.loadUi(os.path.join(os.path.dirname(__file__), "ui_files/Qt4_radiation_damage_model_widget_layout.ui")) # Layout -------------------------------------------------------------- _main_vlayout = QtGui.QVBoxLayout(self) _main_vlayout.addWidget(self.rad_damage_widget) _main_vlayout.setSpacing(0) _main_vlayout.setContentsMargins(0, 0, 0, 0) self.setLayout(_main_vlayout) # Size policies ------------------------------------------------------- # Other --------------------------------------------------------------- self.languageChange() self.setAttribute(QtCore.Qt.WA_WState_Polished) Qt4_widget_colors.set_widget_color(self, Qt4_widget_colors.GROUP_BOX_GRAY)
def centring_successful(self, method, centring_status): """ Descript. : Args. : Return : """ self.full_centring_done = True self.button_centre.command_done() if self.current_centring is not None: self.current_centring = None self.button_accept.setEnabled(True) self.button_reject.setEnabled(True) if self.inside_data_collection: Qt4_widget_colors.set_widget_color(self.button_accept, Qt4_widget_colors.LIGHT_GREEN) Qt4_widget_colors.set_widget_color(self.button_reject, Qt4_widget_colors.LIGHT_RED) if self.collect_hwobj is not None: self.collect_hwobj.setCentringStatus(centring_status) self.graphics_manager_hwobj.set_centring_state(False) self.is_moving = False self.setEnabled(True) self.emit(QtCore.SIGNAL("enableMinidiff"), (True, )) try: successful_method = self.successful_methods[method] except KeyError, diag: pass
def motor_state_changed(self, state): s = state == self.motor_hwobj.READY self.positions_combo.setEnabled(s) Qt4_widget_colors.set_widget_color(self.positions_combo, Qt4_MotorPredefPosBrick.STATE_COLORS[state], QtGui.QPalette.Button) self.setToolTip(state=state)
def collect_items(self, items = [], checked_items = []): """ Descript. : """ self.beamline_setup_hwobj.shape_history_hwobj.de_select_all() for item in checked_items: # update the run-number text incase of re-collect #item.setText(0, item.get_model().get_name()) #Clear status item.setText(1, "") item.reset_style() self.user_stopped = False self.delete_button.setEnabled(False) self.enable_sample_changer_widget(False) self.collecting = True self.collect_button.setText(" Stop ") Qt4_widget_colors.set_widget_color( self.collect_button, Qt4_widget_colors.LIGHT_RED, QtGui.QPalette.Button) self.collect_button.setIcon(QtGui.QIcon(self.stop_pixmap)) self.parent().enable_hutch_menu(False) self.run_cb() try: self.queue_hwobj.execute() except Exception, e: raise e
def __init__(self, parent = None, name = None, fl = 0): """ Descript. : """ QtGui.QWidget.__init__(self, parent, QtCore.Qt.WindowFlags(fl)) if not name: self.setObjectName("CharTypeWidget") # Hardware objects ---------------------------------------------------- # Internal variables -------------------------------------------------- # Graphic elements ---------------------------------------------------- self.charact_type_gbox = QtGui.QGroupBox(self) # Fix the widths of the widgets to make the layout look nicer, # and beacuse the qt layout engine is so tremendosly good. self.charact_type_gbox.setFixedWidth(621) self.charact_type_gbox.setFixedHeight(220) self.charact_type_tbox = QtGui.QToolBox(self.charact_type_gbox) self.routine_dc_page = RoutineDCWidgetLayout(self.charact_type_tbox) self.sad_page = SADWidgetLayout(self.charact_type_tbox) self.rad_damage_page = RadiationDamageWidgetLayout(self.charact_type_tbox) self.charact_type_tbox.addItem(self.routine_dc_page, "Routine-DC") self.charact_type_tbox.addItem(self.sad_page, "SAD") self.charact_type_tbox.addItem(self.rad_damage_page, "Radiation damage") # Layout -------------------------------------------------------------- _charact_type_gbox_vlayout = QtGui.QVBoxLayout(self) _charact_type_gbox_vlayout.addWidget(self.charact_type_tbox) _charact_type_gbox_vlayout.addStretch(0) _charact_type_gbox_vlayout.setSpacing(0) _charact_type_gbox_vlayout.setContentsMargins(0, 0, 0, 0) self.charact_type_gbox.setLayout(_charact_type_gbox_vlayout) _main_vlayout = QtGui.QVBoxLayout(self) _main_vlayout.addWidget(self.charact_type_gbox) _main_vlayout.addStretch(0) _main_vlayout.setSpacing(0) _main_vlayout.setContentsMargins(0, 0, 0, 0) self.setLayout(_main_vlayout) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ self.routine_dc_page.dose_limit_cbx.toggled.connect(\ self.enable_dose_ledit) self.routine_dc_page.time_limit_cbx.toggled.connect(\ self.enable_time_ledit) self.routine_dc_page.dose_time_bgroup.buttonClicked.connect(\ self._toggle_time_dose) # Other --------------------------------------------------------------- self._toggle_time_dose(self.routine_dc_page.dose_time_bgroup.checkedId()) Qt4_widget_colors.set_widget_color(self, Qt4_widget_colors.GROUP_BOX_GRAY)
def humidity_changed(self, value, status_ok): self.humidity_label.setText(" Humidity : %0.1f%s" %(value, chr(37))) if status_ok: Qt4_widget_colors.set_widget_color(self.humidity_label, Qt4_DetectorStatusBrick.STATES['OK']) else: Qt4_widget_colors.set_widget_color(self.humidity_label, Qt4_DetectorStatusBrick.STATES['BAD'])
def set_position_spinbox_color(self, state): """ Descript. : Args. : Return. : """ color = Qt4_MotorSpinBoxBrick.STATE_COLORS[state] Qt4_widget_colors.set_widget_color(self.position_spinbox.lineEdit(), color)
def step_changed(self, step): """ Descript. : Args. : Return. : """ Qt4_widget_colors.set_widget_color(self.step_cbox.lineEdit(), QtCore.Qt.white, QtGui.QPalette.Base)
def status_changed(self, status, status_message): """ """ if status: self.status_label.setText("<b>%s</b>" % status.title()) Qt4_widget_colors.set_widget_color(self.status_label, Qt4_DetectorStatusBrick.DETECTOR_STATES[status]) self.setToolTip(status_message)
def step_changed(self, step): """ Descript. : Args. : Return. : """ Qt4_widget_colors.set_widget_color(self.step_combo.lineEdit(), Qt.white, QPalette.Base)
def __init__(self, *args): """ Descript. : Initiates BlissWidget Brick """ BlissWidget.__init__(self, *args) # Hardware objects ---------------------------------------------------- self.attenuators_hwobj = None # Internal variables -------------------------------------------------- # Properties ---------------------------------------------------------- self.addProperty('mnemonic', 'string', '') self.addProperty('mockup_mnemonic', 'string', '') self.addProperty('formatString', 'formatString', '###.##') # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Graphic elements ---------------------------------------------------- self.group_box = QGroupBox("Transmission", self) current_label = QLabel("Current:", self.group_box) current_label.setFixedWidth(75) self.transmission_ledit = QLineEdit(self.group_box) self.transmission_ledit.setReadOnly(True) set_to_label = QLabel("Set to:", self.group_box) self.new_value_ledit = QLineEdit(self.group_box) # Layout -------------------------------------------------------------- _group_box_gridlayout = 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 = 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 --------------------------------------------------------------- Qt4_widget_colors.set_widget_color(self.new_value_ledit, Qt4_widget_colors.LINE_EDIT_ACTIVE, QPalette.Base) self.new_value_validator = 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")
def reject_clicked(self): """ Descript. : Args. : Return : """ Qt4_widget_colors.set_widget_color(self.accept_button, self.standard_color) self.reject_button.setEnabled(False) self.graphics_manager_hwobj.reject_centring()
def step_edited(self, step): """ Descript. : Args. : Return. : """ Qt4_widget_colors.set_widget_color(self.step_cbox, Qt4_widget_colors.LINE_EDIT_CHANGED, QtGui.QPalette.Button)
def __init__(self, *args): """ Descript. : """ BlissWidget.__init__(self, *args) # Hardware objects ---------------------------------------------------- self.aperture_hwobj = None # Internal values ----------------------------------------------------- # Properties ---------------------------------------------------------- self.addProperty('mnemonic', 'string', '') # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Graphic elements ---------------------------------------------------- self.main_gbox = QGroupBox("Aperture", self) self.aperture_diameter_combo = QComboBox(self.main_gbox) self.aperture_diameter_combo.setMinimumWidth(100) self.aperture_position_combo = QComboBox(self.main_gbox) self.aperture_position_combo.setMinimumWidth(100) # Layout -------------------------------------------------------------- _main_gbox_vlayout = 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 = 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 --------------------------------------------------------------- Qt4_widget_colors.set_widget_color(self.aperture_diameter_combo, Qt4_widget_colors.LIGHT_GREEN, QPalette.Button) Qt4_widget_colors.set_widget_color(self.aperture_position_combo, Qt4_widget_colors.LIGHT_GREEN, QPalette.Button) self.aperture_diameter_combo.setMinimumWidth(100) self.aperture_position_combo.setMinimumWidth(100)
def change_hor_gap(self): try: val = self.hor_pos_dspinbox.value() / 1000.0 self.slitbox_hwobj.set_gap('Hor', val) Qt4_widget_colors.set_widget_color(self.hor_pos_dspinbox, Qt4_SlitsBrick.CONNECTED_COLOR) self.hor_pos_dspinbox.clearFocus() except (ValueError, TypeError): return
def set_position_spinbox_color(self, state): """ Descript. : Args. : Return. : """ color = Qt4_MotorSpinBoxBrick.STATE_COLORS[state] Qt4_widget_colors.set_widget_color(self.position_spinbox.lineEdit(), color, QPalette.Base)
def change_hor_gap(self): try: val = self.hor_pos_dspinbox.value() / 1000.0 self.slitbox_hwobj.set_gap('Hor', val) Qt4_widget_colors.set_widget_color(self.hor_pos_dspinbox, Qt4_SlitsBrick.CONNECTED_COLOR) self.hor_pos_dspinbox.clearFocus() except (ValueError,TypeError): return
def step_edited(self, step): """ Descript. : Args. : Return. : """ Qt4_widget_colors.set_widget_color(self.step_combo, Qt4_widget_colors.LINE_EDIT_CHANGED, QPalette.Button)
def temperature_changed(self, value, status_ok): unit = u'\N{DEGREE SIGN}' self.temperature_label.setText(" Temperature : %0.1f%s" %(value, unit)) if status_ok: Qt4_widget_colors.set_widget_color(self.temperature_label, Qt4_DetectorStatusBrick.STATES['OK']) else: Qt4_widget_colors.set_widget_color(self.temperature_label, Qt4_DetectorStatusBrick.STATES['BAD'])
def propertyChanged(self, property_name, old_value, new_value): if property_name == 'label': if new_value == "" and self.motor_hwobj is not None: self.label.setText("<i>" + self.motor_hwobj.username + ":</i>") else: self.label.setText(new_value) elif property_name == 'mnemonic': if self.motor_hwobj is not None: self.disconnect(self.motor_hwobj, 'stateChanged', self.motor_state_changed) self.disconnect(self.motor_hwobj, 'newPredefinedPositions', self.fill_positions) self.disconnect(self.motor_hwobj, 'predefinedPositionChanged', self.predefined_position_changed) self.motor_hwobj = self.getHardwareObject(new_value) if self.motor_hwobj is not None: self.connect(self.motor_hwobj, 'newPredefinedPositions', self.fill_positions) self.connect(self.motor_hwobj, 'stateChanged', self.motor_state_changed) self.connect(self.motor_hwobj, 'predefinedPositionChanged', self.predefined_position_changed) self.fill_positions() if self.motor_hwobj.isReady(): self.predefined_position_changed(self.motor_hwobj.getCurrentPositionName(), 0) if self['label'] == "": lbl=self.motor_hwobj.username self.label.setText("<i>" + lbl + ":</i>") Qt4_widget_colors.set_widget_color(self.positions_combo, Qt4_MotorPredefPosBrick.STATE_COLORS[0], QPalette.Button) self.motor_state_changed(self.motor_hwobj.getState()) elif property_name == 'showMoveButtons': if new_value: self.previous_position_button.show() self.next_position_button.show() else: self.previous_position_button.hide() self.next_position_button.hide() elif property_name == 'icons': icons_list = new_value.split() try: self.previous_position_button.setIcon(\ Qt4_Icons.load_icon(icons_list[0])) self.next_position_button.setIcon(\ Qt4_Icons.load_icon(icons_list[1])) except: pass else: BlissWidget.propertyChanged(self,property_name, old_value, new_value)
def __init__(self, *args): """ Descript. : """ BlissWidget.__init__(self, *args) # Hardware objects ---------------------------------------------------- self.aperture_hwobj = None # Internal values ----------------------------------------------------- # Properties ---------------------------------------------------------- self.addProperty('mnemonic', 'string', '') # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Graphic elements ---------------------------------------------------- self.main_gbox = QtGui.QGroupBox("Aperture", self) self.aperture_diameter_combo = QtGui.QComboBox(self.main_gbox) self.aperture_diameter_combo.setMinimumWidth(100) self.aperture_position_combo = QtGui.QComboBox(self.main_gbox) self.aperture_position_combo.setMinimumWidth(100) # Layout -------------------------------------------------------------- _main_gbox_vlayout = QtGui.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(2, 2, 2, 2) _main_vlayout = QtGui.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 --------------------------------------------------------------- Qt4_widget_colors.set_widget_color(self.aperture_diameter_combo, Qt4_widget_colors.LIGHT_GREEN, QtGui.QPalette.Button) Qt4_widget_colors.set_widget_color(self.aperture_position_combo, Qt4_widget_colors.LIGHT_GREEN, QtGui.QPalette.Button) self.aperture_diameter_combo.setMinimumWidth(100) self.aperture_position_combo.setMinimumWidth(100)
def change_ver_gap(self): try: #val = self.ver_pos_dspinbox.value() / float (10**self.decimalPlaces) val = self.ver_pos_dspinbox.value() / 1000.0 self.slitbox_hwobj.set_gap('Ver', val) Qt4_widget_colors.set_widget_color(self.ver_pos_dspinbox, Qt4_SlitsBrick.CONNECTED_COLOR) self.ver_pos_dspinbox.clearFocus() except (ValueError, TypeError): return
def accept_clicked(self): """ Descript. : Args. : Return : """ Qt4_widget_colors.set_widget_color(self.accept_button, self.standard_color) self.reject_button.setEnabled(False) self.graphics_manager_hwobj.accept_centring()
def selectionTextChanged(self, txt): if self.standard_color is None: self.standard_color = Qt4_widget_colors.WHITE if txt == str(self.currentSelection): if self.standard_color is not None: self.selected_spinbox.editor().setPaletteBackgroundColor(self.standard_color) # state = True else: Qt4_widget_colors.set_widget_color(self.selected_spinbox.lineEdit(), Qt4_widget_colors.LIGHT_YELLOW)
def __init__(self, *args): """ Descript. : """ BlissWidget.__init__(self, *args) self.logger = logging.getLogger("GUI Alba Actuator") self.logger.info("__init__()") self.on_color = Qt4_widget_colors.color_to_hexa( Qt4_widget_colors.LIGHT_GREEN) self.off_color = Qt4_widget_colors.color_to_hexa( Qt4_widget_colors.LIGHT_GRAY) self.fault_color = Qt4_widget_colors.color_to_hexa( Qt4_widget_colors.LIGHT_RED) self.unknown_color = Qt4_widget_colors.color_to_hexa( Qt4_widget_colors.DARK_GRAY) # Hardware objects ---------------------------------------------------- self.light_ho = None self.state = None self.level = None self.icons = None self.level_limits = [None, None] # Properties ---------------------------------------------------------- self.addProperty('mnemonic', 'string', '') self.addProperty('icons', 'string', '') # Graphic elements ---------------------------------------------------- self.widget = uic.loadUi( os.path.join(os.path.dirname(__file__), 'widgets/ui_files/alba_lightcontrol.ui')) QtGui.QHBoxLayout(self) self.layout().addWidget(self.widget) self.layout().setContentsMargins(0, 0, 0, 0) self.widget.layout().setContentsMargins(0, 0, 0, 0) self.widget.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.widget.button.clicked.connect(self.do_switch) self.widget.slider.valueChanged.connect(self.do_set_level) # SizePolicies -------------------------------------------------------- self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.MinimumExpanding) # Defaults self.set_icons('BulbCheck,BulbDelete') # Other --------------------------------------------------------------- self.setToolTip("Control of light (set level and on/off switch.") self.update()
def command_done(self): """ Descript. : Args. : Return : """ self.executing = False Qt4_widget_colors.set_widget_color(self, self.standard_color) if self.run_icon is not None: self.setIcon(self.run_icon) self.setEnabled(True)
def user_group_changed(self, value): """ Descript. : """ if self.saved_group: msg = 'User group changed, press set to apply change' logging.getLogger("user_level_log").warning(msg) Qt4_widget_colors.set_widget_color( self.user_group_ledit, Qt4_widget_colors.LINE_EDIT_CHANGED, QtGui.QPalette.Base) self.saved_group = False
def subwedge_size_ledit_change(self, new_value): """ Descript. : """ if int(new_value) > self._acquisition_parameters.num_images: Qt4_widget_colors.set_widget_color(\ self.acq_widget.subwedge_size_ledit, Qt4_widget_colors.LIGHT_RED) else: Qt4_widget_colors.set_widget_color( self.acq_widget.subwedge_size_ledit, Qt4_widget_colors.WHITE)
def command_started(self): """ Descript. : Args. : Return : """ Qt4_widget_colors.set_widget_color(self, QtCore.Qt.yellow) if self.stop_icon is not None: self.setIcon(self.stop_icon) self.executing = True self.setEnabled(True)