def __init__(self, parent=None, name="xrf_spectrum_parameters_widget"): QtGui.QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Hardware objects ---------------------------------------------------- self.xrf_spectrum_hwobj = None # Internal variables -------------------------------------------------- self.xrf_spectrum_model = queue_model_objects.XRFSpectrum() self._tree_view_item = None # Graphic elements ---------------------------------------------------- _top_widget = QtGui.QWidget(self) _parameters_widget = QtGui.QWidget(_top_widget) self.data_path_widget = DataPathWidget(_parameters_widget) self.other_parameters_gbox = QtGui.QGroupBox("Other parameters", _parameters_widget) self.count_time_label = QtGui.QLabel("Count time:", self.other_parameters_gbox) self.count_time_ledit = QtGui.QLineEdit(self.other_parameters_gbox) self.count_time_ledit.setFixedWidth(50) self.adjust_transmission_cbox = QtGui.QCheckBox("Adjust transmission", \ self.other_parameters_gbox) self.adjust_transmission_cbox.hide() _snapshot_widget = QtGui.QWidget(self) self.position_widget = uic.loadUi( os.path.join(os.path.dirname(__file__), 'ui_files/Qt4_snapshot_widget_layout.ui')) self.mca_spectrum_widget = McaSpectrumWidget(self) # Layout ------------------------------------------------------------- _other_parameters_gbox_hlayout = QtGui.QHBoxLayout( self.other_parameters_gbox) _other_parameters_gbox_hlayout.addWidget(self.count_time_label) _other_parameters_gbox_hlayout.addWidget(self.count_time_ledit) _other_parameters_gbox_hlayout.addWidget(self.adjust_transmission_cbox) _other_parameters_gbox_hlayout.addStretch(0) _other_parameters_gbox_hlayout.setSpacing(2) _other_parameters_gbox_hlayout.setContentsMargins(3, 3, 3, 3) _parameters_widget_layout = QtGui.QVBoxLayout(_parameters_widget) _parameters_widget_layout.addWidget(self.data_path_widget) _parameters_widget_layout.addWidget(self.other_parameters_gbox) _parameters_widget_layout.addStretch(0) _parameters_widget_layout.setSpacing(2) _parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _snapshots_vlayout = QtGui.QVBoxLayout(_snapshot_widget) _snapshots_vlayout.addWidget(self.position_widget) _snapshots_vlayout.setContentsMargins(0, 0, 0, 0) _snapshots_vlayout.setSpacing(2) _snapshots_vlayout.addStretch(0) _top_widget_layout = QtGui.QHBoxLayout(_top_widget) _top_widget_layout.addWidget(_parameters_widget) _top_widget_layout.addWidget(_snapshot_widget) _top_widget_layout.setSpacing(2) _top_widget_layout.addStretch(0) _top_widget_layout.setContentsMargins(0, 0, 0, 0) _main_vlayout = QtGui.QVBoxLayout(self) _main_vlayout.addWidget(_top_widget) _main_vlayout.addWidget(self.mca_spectrum_widget) _main_vlayout.setSpacing(2) _main_vlayout.setContentsMargins(0, 0, 0, 0) # SizePolicies ------------------------------------------------------- self.position_widget.setFixedSize(457, 350) self.mca_spectrum_widget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) _top_widget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) # Qt signal/slot connections ------------------------------------------ self.data_path_widget.data_path_layout.prefix_ledit.\ textChanged.connect(self._prefix_ledit_change) self.data_path_widget.data_path_layout.run_number_ledit.\ textChanged.connect(self._run_number_ledit_change) self.count_time_ledit.textChanged.connect( self._count_time_ledit_change)
def __init__(self, parent = None, name = "xrf_scan_tab_widget"): QtGui.QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Hardware objects ---------------------------------------------------- self.xrf_scan_hwobj = None # Internal variables -------------------------------------------------- self.xrf_scan_model = queue_model_objects.XRFScan() self._tree_view_item = None # Graphic elements ---------------------------------------------------- _top_widget = QtGui.QWidget(self) _parameters_widget = QtGui.QWidget(_top_widget) self.data_path_widget = DataPathWidget(_parameters_widget) self.other_parameters_gbox = QtGui.QGroupBox("Other parameters", _parameters_widget) self.count_time_label = QtGui.QLabel("Count time:", self.other_parameters_gbox) self.count_time_ledit = QtGui.QLineEdit(self.other_parameters_gbox) self.count_time_ledit.setFixedWidth(50) self.adjust_transmission_cbox = QtGui.QCheckBox("Adjust transmission", \ self.other_parameters_gbox) self.adjust_transmission_cbox.hide() _snapshot_widget = QtGui.QWidget(self) self.position_widget = uic.loadUi(os.path.join(os.path.dirname(__file__), 'ui_files/Qt4_snapshot_widget_layout.ui')) self.mca_spectrum_widget = McaSpectrumWidget(self) # Layout ------------------------------------------------------------- _other_parameters_gbox_hlayout = QtGui.QHBoxLayout(self.other_parameters_gbox) _other_parameters_gbox_hlayout.addWidget(self.count_time_label) _other_parameters_gbox_hlayout.addWidget(self.count_time_ledit) _other_parameters_gbox_hlayout.addWidget(self.adjust_transmission_cbox) _other_parameters_gbox_hlayout.addStretch(0) _other_parameters_gbox_hlayout.setSpacing(2) _other_parameters_gbox_hlayout.setContentsMargins(3, 3, 3, 3) _parameters_widget_layout = QtGui.QVBoxLayout(_parameters_widget) _parameters_widget_layout.addWidget(self.data_path_widget) _parameters_widget_layout.addWidget(self.other_parameters_gbox) _parameters_widget_layout.addStretch(0) _parameters_widget_layout.setSpacing(2) _parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _snapshots_vlayout = QtGui.QVBoxLayout(_snapshot_widget) _snapshots_vlayout.addWidget(self.position_widget) _snapshots_vlayout.setContentsMargins(0, 0, 0, 0) _snapshots_vlayout.setSpacing(2) _snapshots_vlayout.addStretch(0) _top_widget_layout = QtGui.QHBoxLayout(_top_widget) _top_widget_layout.addWidget(_parameters_widget) _top_widget_layout.addWidget(_snapshot_widget) _top_widget_layout.setSpacing(2) _top_widget_layout.setContentsMargins(0, 0, 0, 0) _main_vlayout = QtGui.QVBoxLayout(self) _main_vlayout.addWidget(_top_widget) _main_vlayout.addWidget(self.mca_spectrum_widget) _main_vlayout.setSpacing(2) _main_vlayout.setContentsMargins(0, 0, 0, 0) # SizePolicies ------------------------------------------------------- self.position_widget.setFixedSize(457, 350) self.mca_spectrum_widget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) _top_widget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) # Qt signal/slot connections ------------------------------------------ self.data_path_widget.data_path_layout.prefix_ledit.\ textChanged.connect(self._prefix_ledit_change) self.data_path_widget.data_path_layout.run_number_ledit.\ textChanged.connect(self._run_number_ledit_change) self.count_time_ledit.textChanged.connect(self._count_time_ledit_change) # Other --------------------------------------------------------------- Qt4_widget_colors.set_widget_color(self.other_parameters_gbox, Qt4_widget_colors.GROUP_BOX_GRAY) Qt4_widget_colors.set_widget_color(self.data_path_widget, Qt4_widget_colors.GROUP_BOX_GRAY) Qt4_widget_colors.set_widget_color(self.position_widget, Qt4_widget_colors.GROUP_BOX_GRAY)
class XRFSpectrumParametersWidget(QtGui.QWidget): def __init__(self, parent=None, name="xrf_spectrum_parameters_widget"): QtGui.QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Hardware objects ---------------------------------------------------- self.xrf_spectrum_hwobj = None # Internal variables -------------------------------------------------- self.xrf_spectrum_model = queue_model_objects.XRFSpectrum() self._tree_view_item = None # Graphic elements ---------------------------------------------------- _top_widget = QtGui.QWidget(self) _parameters_widget = QtGui.QWidget(_top_widget) self.data_path_widget = DataPathWidget(_parameters_widget) self.other_parameters_gbox = QtGui.QGroupBox("Other parameters", _parameters_widget) self.count_time_label = QtGui.QLabel("Count time:", self.other_parameters_gbox) self.count_time_ledit = QtGui.QLineEdit(self.other_parameters_gbox) self.count_time_ledit.setFixedWidth(50) self.adjust_transmission_cbox = QtGui.QCheckBox("Adjust transmission", \ self.other_parameters_gbox) self.adjust_transmission_cbox.hide() _snapshot_widget = QtGui.QWidget(self) self.position_widget = uic.loadUi( os.path.join(os.path.dirname(__file__), 'ui_files/Qt4_snapshot_widget_layout.ui')) self.mca_spectrum_widget = McaSpectrumWidget(self) # Layout ------------------------------------------------------------- _other_parameters_gbox_hlayout = QtGui.QHBoxLayout( self.other_parameters_gbox) _other_parameters_gbox_hlayout.addWidget(self.count_time_label) _other_parameters_gbox_hlayout.addWidget(self.count_time_ledit) _other_parameters_gbox_hlayout.addWidget(self.adjust_transmission_cbox) _other_parameters_gbox_hlayout.addStretch(0) _other_parameters_gbox_hlayout.setSpacing(2) _other_parameters_gbox_hlayout.setContentsMargins(3, 3, 3, 3) _parameters_widget_layout = QtGui.QVBoxLayout(_parameters_widget) _parameters_widget_layout.addWidget(self.data_path_widget) _parameters_widget_layout.addWidget(self.other_parameters_gbox) _parameters_widget_layout.addStretch(0) _parameters_widget_layout.setSpacing(2) _parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _snapshots_vlayout = QtGui.QVBoxLayout(_snapshot_widget) _snapshots_vlayout.addWidget(self.position_widget) _snapshots_vlayout.setContentsMargins(0, 0, 0, 0) _snapshots_vlayout.setSpacing(2) _snapshots_vlayout.addStretch(0) _top_widget_layout = QtGui.QHBoxLayout(_top_widget) _top_widget_layout.addWidget(_parameters_widget) _top_widget_layout.addWidget(_snapshot_widget) _top_widget_layout.setSpacing(2) _top_widget_layout.addStretch(0) _top_widget_layout.setContentsMargins(0, 0, 0, 0) _main_vlayout = QtGui.QVBoxLayout(self) _main_vlayout.addWidget(_top_widget) _main_vlayout.addWidget(self.mca_spectrum_widget) _main_vlayout.setSpacing(2) _main_vlayout.setContentsMargins(0, 0, 0, 0) # SizePolicies ------------------------------------------------------- self.position_widget.setFixedSize(457, 350) self.mca_spectrum_widget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) _top_widget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) # Qt signal/slot connections ------------------------------------------ self.data_path_widget.data_path_layout.prefix_ledit.\ textChanged.connect(self._prefix_ledit_change) self.data_path_widget.data_path_layout.run_number_ledit.\ textChanged.connect(self._run_number_ledit_change) self.count_time_ledit.textChanged.connect( self._count_time_ledit_change) # Other --------------------------------------------------------------- def _prefix_ledit_change(self, new_value): self.xrf_spectrum_model.set_name(str(new_value)) self._tree_view_item.setText( 0, self.xrf_spectrum_model.get_display_name()) def _run_number_ledit_change(self, new_value): if str(new_value).isdigit(): self.xrf_spectrum_model.set_number(int(new_value)) self._tree_view_item.setText( 0, self.xrf_spectrum_model.get_display_name()) def _count_time_ledit_change(self, new_value): if str(new_value).isdigit(): self.xrf_spectrum_model.set_count_time(float(new_value)) def tab_changed(self): if self._tree_view_item: self.populate_widget(self._tree_view_item) def populate_widget(self, item): self._tree_view_item = item self.xrf_spectrum_model = item.get_model() executed = self.xrf_spectrum_model.is_executed() self.data_path_widget.setEnabled(not executed) self.other_parameters_gbox.setEnabled(not executed) self.mca_spectrum_widget.setEnabled(executed) if executed: result = self.xrf_spectrum_model.get_scan_result() self.mca_spectrum_widget.setData(result.mca_data, result.mca_calib, result.mca_config) else: self.mca_spectrum_widget.clear() self.data_path_widget.update_data_model( self.xrf_spectrum_model.path_template) self.count_time_ledit.setText(str(self.xrf_spectrum_model.count_time)) image = self.xrf_spectrum_model.centred_position.snapshot_image if image is not None: try: image = image.scaled(427, 320, QtCore.Qt.KeepAspectRatio) self.position_widget.svideo.setPixmap(QtGui.QPixmap(image)) except: pass def set_xrf_spectrum_hwobj(self, xrf_spectrum_hwobj): self.xrf_spectrum_hwobj = xrf_spectrum_hwobj if self.xrf_spectrum_hwobj: self.xrf_spectrum_hwobj.connect("xrfSpectrumFinished", self.spectrum_finished) def spectrum_finished(self, mca_data, mca_calib, mca_config): self.mca_spectrum_widget.set_data(mca_data, mca_calib, mca_config)
def __init__(self, parent = None, name = "xrf_spectrum_parameters_widget"): QtGui.QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Hardware objects ---------------------------------------------------- self.xrf_spectrum_hwobj = None # Internal variables -------------------------------------------------- self.xrf_spectrum_model = queue_model_objects.XRFSpectrum() self._tree_view_item = None # Graphic elements ---------------------------------------------------- _top_widget = QtGui.QWidget(self) _parameters_widget = QtGui.QWidget(_top_widget) self.data_path_widget = DataPathWidget(_parameters_widget) self.other_parameters_gbox = QtGui.QGroupBox("Other parameters", _parameters_widget) self.count_time_label = QtGui.QLabel("Count time:", self.other_parameters_gbox) self.count_time_ledit = QtGui.QLineEdit(self.other_parameters_gbox) self.count_time_ledit.setFixedWidth(50) self.adjust_transmission_cbox = QtGui.QCheckBox("Adjust transmission", \ self.other_parameters_gbox) self.adjust_transmission_cbox.hide() self.mca_spectrum_widget = McaSpectrumWidget(self) self.snapshot_widget = SnapshotWidget(self) # Layout ------------------------------------------------------------- _other_parameters_gbox_hlayout = QtGui.QHBoxLayout(self.other_parameters_gbox) _other_parameters_gbox_hlayout.addWidget(self.count_time_label) _other_parameters_gbox_hlayout.addWidget(self.count_time_ledit) _other_parameters_gbox_hlayout.addWidget(self.adjust_transmission_cbox) _other_parameters_gbox_hlayout.addStretch(0) _other_parameters_gbox_hlayout.setSpacing(2) _other_parameters_gbox_hlayout.setContentsMargins(0, 0, 0, 0) _parameters_widget_layout = QtGui.QVBoxLayout(_parameters_widget) _parameters_widget_layout.addWidget(self.data_path_widget) _parameters_widget_layout.addWidget(self.other_parameters_gbox) _parameters_widget_layout.addStretch(0) _parameters_widget_layout.setSpacing(2) _parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _top_widget_layout = QtGui.QHBoxLayout(_top_widget) _top_widget_layout.addWidget(_parameters_widget) _top_widget_layout.addWidget(self.snapshot_widget) _top_widget_layout.setSpacing(2) _top_widget_layout.addStretch(0) _top_widget_layout.setContentsMargins(0, 0, 0, 0) _main_vlayout = QtGui.QVBoxLayout(self) _main_vlayout.addWidget(_top_widget) _main_vlayout.addWidget(self.mca_spectrum_widget) _main_vlayout.setSpacing(2) _main_vlayout.setContentsMargins(0, 0, 0, 0) # SizePolicies ------------------------------------------------------- self.mca_spectrum_widget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) _top_widget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) # Qt signal/slot connections ------------------------------------------ self.data_path_widget.data_path_layout.prefix_ledit.textChanged.\ connect(self._prefix_ledit_change) self.data_path_widget.data_path_layout.run_number_ledit.textChanged.\ connect(self._run_number_ledit_change) self.count_time_ledit.textChanged.connect(\ self._count_time_ledit_change)
class XRFScanParametersWidget(QtGui.QWidget): def __init__(self, parent = None, name = "xrf_scan_tab_widget"): QtGui.QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Hardware objects ---------------------------------------------------- self.xrf_scan_hwobj = None # Internal variables -------------------------------------------------- self.xrf_scan_model = queue_model_objects.XRFScan() self._tree_view_item = None # Graphic elements ---------------------------------------------------- _top_widget = QtGui.QWidget(self) _parameters_widget = QtGui.QWidget(_top_widget) self.data_path_widget = DataPathWidget(_parameters_widget) self.other_parameters_gbox = QtGui.QGroupBox("Other parameters", _parameters_widget) self.count_time_label = QtGui.QLabel("Count time:", self.other_parameters_gbox) self.count_time_ledit = QtGui.QLineEdit(self.other_parameters_gbox) self.count_time_ledit.setFixedWidth(50) self.adjust_transmission_cbox = QtGui.QCheckBox("Adjust transmission", \ self.other_parameters_gbox) self.adjust_transmission_cbox.hide() _snapshot_widget = QtGui.QWidget(self) self.position_widget = uic.loadUi(os.path.join(os.path.dirname(__file__), 'ui_files/Qt4_snapshot_widget_layout.ui')) self.mca_spectrum_widget = McaSpectrumWidget(self) # Layout ------------------------------------------------------------- _other_parameters_gbox_hlayout = QtGui.QHBoxLayout(self.other_parameters_gbox) _other_parameters_gbox_hlayout.addWidget(self.count_time_label) _other_parameters_gbox_hlayout.addWidget(self.count_time_ledit) _other_parameters_gbox_hlayout.addWidget(self.adjust_transmission_cbox) _other_parameters_gbox_hlayout.addStretch(0) _other_parameters_gbox_hlayout.setSpacing(2) _other_parameters_gbox_hlayout.setContentsMargins(3, 3, 3, 3) _parameters_widget_layout = QtGui.QVBoxLayout(_parameters_widget) _parameters_widget_layout.addWidget(self.data_path_widget) _parameters_widget_layout.addWidget(self.other_parameters_gbox) _parameters_widget_layout.addStretch(0) _parameters_widget_layout.setSpacing(2) _parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _snapshots_vlayout = QtGui.QVBoxLayout(_snapshot_widget) _snapshots_vlayout.addWidget(self.position_widget) _snapshots_vlayout.setContentsMargins(0, 0, 0, 0) _snapshots_vlayout.setSpacing(2) _snapshots_vlayout.addStretch(0) _top_widget_layout = QtGui.QHBoxLayout(_top_widget) _top_widget_layout.addWidget(_parameters_widget) _top_widget_layout.addWidget(_snapshot_widget) _top_widget_layout.setSpacing(2) _top_widget_layout.setContentsMargins(0, 0, 0, 0) _main_vlayout = QtGui.QVBoxLayout(self) _main_vlayout.addWidget(_top_widget) _main_vlayout.addWidget(self.mca_spectrum_widget) _main_vlayout.setSpacing(2) _main_vlayout.setContentsMargins(0, 0, 0, 0) # SizePolicies ------------------------------------------------------- self.position_widget.setFixedSize(457, 350) self.mca_spectrum_widget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) _top_widget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) # Qt signal/slot connections ------------------------------------------ self.data_path_widget.data_path_layout.prefix_ledit.\ textChanged.connect(self._prefix_ledit_change) self.data_path_widget.data_path_layout.run_number_ledit.\ textChanged.connect(self._run_number_ledit_change) self.count_time_ledit.textChanged.connect(self._count_time_ledit_change) # Other --------------------------------------------------------------- Qt4_widget_colors.set_widget_color(self.other_parameters_gbox, Qt4_widget_colors.GROUP_BOX_GRAY) Qt4_widget_colors.set_widget_color(self.data_path_widget, Qt4_widget_colors.GROUP_BOX_GRAY) Qt4_widget_colors.set_widget_color(self.position_widget, Qt4_widget_colors.GROUP_BOX_GRAY) def _prefix_ledit_change(self, new_value): self.xrf_scan_model.set_name(str(new_value)) self._tree_view_item.setText(0, self.xrf_scan_model.get_display_name()) def _run_number_ledit_change(self, new_value): if str(new_value).isdigit(): self.xrf_scan_model.set_number(int(new_value)) self._tree_view_item.setText(0, self.xrf_scan_model.get_display_name()) def _count_time_ledit_change(self, new_value): if str(new_value).isdigit(): self.xrf_scan_model.set_count_time(float(new_value)) def tab_changed(self): if self._tree_view_item: self.populate_widget(self._tree_view_item) def populate_widget(self, item): self._tree_view_item = item self.xrf_scan_model = item.get_model() executed = self.xrf_scan_model.is_executed() self.data_path_widget.setEnabled(not executed) self.other_parameters_gbox.setEnabled(not executed) self.mca_spectrum_widget.setEnabled(executed) if executed: result = self.xrf_scan_model.get_scan_result() self.mca_spectrum_widget.setData(result.mca_data, result.mca_calib, result.mca_config) else: self.mca_spectrum_widget.clear() self.data_path_widget.update_data_model(self.xrf_scan_model.path_template) self.count_time_ledit.setText(str(self.xrf_scan_model.count_time)) image = self.xrf_scan_model.centred_position.snapshot_image if image is not None: try: image = image.scaled(427, 320, QtCore.Qt.KeepAspectRatio) self.position_widget.svideo.setPixmap(QtGui.QPixmap(image)) except: pass def set_xrf_scan_hwobj(self, xrf_scan_hwobj): self.xrf_scan_hwobj = xrf_scan_hwobj if self.xrf_scan_hwobj: self.xrf_scan_hwobj.connect("xrfScanFinished", self.scan_finished) def scan_finished(self, mcaData, mcaCalib, mcaConfig): self.mca_spectrum_widget.setData(mcaData, mcaCalib, mcaConfig)
class XRFSpectrumParametersWidget(QtGui.QWidget): def __init__(self, parent = None, name = "xrf_spectrum_parameters_widget"): QtGui.QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Hardware objects ---------------------------------------------------- self.xrf_spectrum_hwobj = None # Internal variables -------------------------------------------------- self.xrf_spectrum_model = queue_model_objects.XRFSpectrum() self._tree_view_item = None # Graphic elements ---------------------------------------------------- _top_widget = QtGui.QWidget(self) _parameters_widget = QtGui.QWidget(_top_widget) self.data_path_widget = DataPathWidget(_parameters_widget) self.other_parameters_gbox = QtGui.QGroupBox("Other parameters", _parameters_widget) self.count_time_label = QtGui.QLabel("Count time:", self.other_parameters_gbox) self.count_time_ledit = QtGui.QLineEdit(self.other_parameters_gbox) self.count_time_ledit.setFixedWidth(50) self.adjust_transmission_cbox = QtGui.QCheckBox("Adjust transmission", \ self.other_parameters_gbox) self.adjust_transmission_cbox.hide() self.mca_spectrum_widget = McaSpectrumWidget(self) self.snapshot_widget = SnapshotWidget(self) # Layout ------------------------------------------------------------- _other_parameters_gbox_hlayout = QtGui.QHBoxLayout(self.other_parameters_gbox) _other_parameters_gbox_hlayout.addWidget(self.count_time_label) _other_parameters_gbox_hlayout.addWidget(self.count_time_ledit) _other_parameters_gbox_hlayout.addWidget(self.adjust_transmission_cbox) _other_parameters_gbox_hlayout.addStretch(0) _other_parameters_gbox_hlayout.setSpacing(2) _other_parameters_gbox_hlayout.setContentsMargins(0, 0, 0, 0) _parameters_widget_layout = QtGui.QVBoxLayout(_parameters_widget) _parameters_widget_layout.addWidget(self.data_path_widget) _parameters_widget_layout.addWidget(self.other_parameters_gbox) _parameters_widget_layout.addStretch(0) _parameters_widget_layout.setSpacing(2) _parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _top_widget_layout = QtGui.QHBoxLayout(_top_widget) _top_widget_layout.addWidget(_parameters_widget) _top_widget_layout.addWidget(self.snapshot_widget) _top_widget_layout.setSpacing(2) _top_widget_layout.addStretch(0) _top_widget_layout.setContentsMargins(0, 0, 0, 0) _main_vlayout = QtGui.QVBoxLayout(self) _main_vlayout.addWidget(_top_widget) _main_vlayout.addWidget(self.mca_spectrum_widget) _main_vlayout.setSpacing(2) _main_vlayout.setContentsMargins(0, 0, 0, 0) # SizePolicies ------------------------------------------------------- self.mca_spectrum_widget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) _top_widget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) # Qt signal/slot connections ------------------------------------------ self.data_path_widget.data_path_layout.prefix_ledit.textChanged.\ connect(self._prefix_ledit_change) self.data_path_widget.data_path_layout.run_number_ledit.textChanged.\ connect(self._run_number_ledit_change) self.count_time_ledit.textChanged.connect(\ self._count_time_ledit_change) # Other --------------------------------------------------------------- def _prefix_ledit_change(self, new_value): self.xrf_spectrum_model.set_name(str(new_value)) self._tree_view_item.setText(\ 0, self.xrf_spectrum_model.get_display_name()) def _run_number_ledit_change(self, new_value): if str(new_value).isdigit(): self.xrf_spectrum_model.set_number(int(new_value)) self._tree_view_item.setText(\ 0, self.xrf_spectrum_model.get_display_name()) def _count_time_ledit_change(self, new_value): if str(new_value).isdigit(): self.xrf_spectrum_model.set_count_time(float(new_value)) def tab_changed(self): if self._tree_view_item: self.populate_widget(self._tree_view_item) def populate_widget(self, item): self._tree_view_item = item self.xrf_spectrum_model = item.get_model() executed = self.xrf_spectrum_model.is_executed() self.data_path_widget.setEnabled(not executed) self.other_parameters_gbox.setEnabled(not executed) #self.mca_spectrum_widget.setEnabled(executed) if executed: result = self.xrf_spectrum_model.get_spectrum_result() self.mca_spectrum_widget.set_data(result.mca_data, result.mca_calib, result.mca_config) else: self.mca_spectrum_widget.clear() self.data_path_widget.update_data_model(\ self.xrf_spectrum_model.path_template) self.count_time_ledit.setText(\ str(self.xrf_spectrum_model.count_time)) image = self.xrf_spectrum_model.centred_position.snapshot_image self.snapshot_widget.display_snapshot(image, width=400) def set_xrf_spectrum_hwobj(self, xrf_spectrum_hwobj): if self.xrf_spectrum_hwobj is None: self.xrf_spectrum_hwobj = xrf_spectrum_hwobj self.xrf_spectrum_hwobj.connect("xrfSpectrumFinished", self.spectrum_finished) def spectrum_finished(self, mca_data, mca_calib, mca_config): self.mca_spectrum_widget.set_data(mca_data, mca_calib, mca_config)
def __init__(self, parent = None, name = "xrf_scan_tab_widget"): QtGui.QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Hardware objects ---------------------------------------------------- self.xrf_scan_hwobj = None # Internal variables -------------------------------------------------- self.xrf_scan_model = queue_model_objects.XRFScan() self._tree_view_item = None # Graphic elements ---------------------------------------------------- _top_widget = QtGui.QWidget(self) _parameters_widget = QtGui.QWidget(_top_widget) self.data_path_widget = DataPathWidget(_parameters_widget) self.other_parameters_gbox = QtGui.QGroupBox("Other parameters", _parameters_widget) self.count_time_label = QtGui.QLabel("Count time:", self.other_parameters_gbox) self.count_time_ledit = QtGui.QLineEdit(self.other_parameters_gbox) self.count_time_ledit.setFixedWidth(50) self.position_widget = uic.loadUi(os.path.join(os.path.dirname(__file__), 'ui_files/Qt4_snapshot_widget_layout.ui')) self.mca_spectrum_widget = McaSpectrumWidget(self) # Layout ------------------------------------------------------------- self.other_parameters_gbox_layout = QtGui.QHBoxLayout(self) self.other_parameters_gbox_layout.addWidget(self.count_time_label) self.other_parameters_gbox_layout.addWidget(self.count_time_ledit) self.other_parameters_gbox_layout.addStretch(0) self.other_parameters_gbox_layout.setSpacing(2) self.other_parameters_gbox_layout.setContentsMargins(3, 3, 3, 3) self.other_parameters_gbox.setLayout(self.other_parameters_gbox_layout) _parameters_widget_layout = QtGui.QVBoxLayout() _parameters_widget_layout.addWidget(self.data_path_widget) _parameters_widget_layout.addWidget(self.other_parameters_gbox) _parameters_widget_layout.addStretch(0) _parameters_widget_layout.setSpacing(2) _parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _parameters_widget.setLayout(_parameters_widget_layout) _top_widget_layout = QtGui.QHBoxLayout(_top_widget) _top_widget_layout.addWidget(_parameters_widget) _top_widget_layout.addWidget(self.position_widget) _top_widget_layout.setSpacing(2) _top_widget_layout.setContentsMargins(0, 0, 0, 0) _top_widget.setLayout(_top_widget_layout) _main_vlayout = QtGui.QVBoxLayout(self) _main_vlayout.addWidget(_top_widget) _main_vlayout.addWidget(self.mca_spectrum_widget) _main_vlayout.setSpacing(2) _main_vlayout.setContentsMargins(0, 0, 0, 0) self.setLayout(_main_vlayout) # SizePolicies ------------------------------------------------------- self.position_widget.setFixedSize(457, 350) self.mca_spectrum_widget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) _top_widget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) #self.mca_spectrum_widget.setMinimumHeight(800) #self.setSizePolicy(QtGui.QSizePolicy.Expanding, # QtGui.QSizePolicy.Fixed) # Qt signal/slot connections ------------------------------------------ QtCore.QObject.connect(self.data_path_widget.data_path_layout.\ findChild(QtGui.QLineEdit, 'prefix_ledit'), QtCore.SIGNAL("textChanged(const QString &)"), self._prefix_ledit_change) QtCore.QObject.connect(self.data_path_widget.data_path_layout.\ findChild(QtGui.QLineEdit, 'run_number_ledit'), QtCore.SIGNAL("textChanged(const QString &)"), self._run_number_ledit_change) QtCore.QObject.connect(self.count_time_ledit, QtCore.SIGNAL("textChanged(const QString &)"), self._count_time_ledit_change) #QtCore.QObject.connect(.qApp, qt.PYSIGNAL('tab_changed'), # self.tab_changed) # Other --------------------------------------------------------------- Qt4_widget_colors.set_widget_color(self.other_parameters_gbox, Qt4_widget_colors.GROUP_BOX_GRAY) Qt4_widget_colors.set_widget_color(self.data_path_widget, Qt4_widget_colors.GROUP_BOX_GRAY) Qt4_widget_colors.set_widget_color(self.position_widget, Qt4_widget_colors.GROUP_BOX_GRAY)
class XRFSpectrumParametersWidget(QWidget): def __init__(self, parent=None, name="xrf_spectrum_parameters_widget"): QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Hardware objects ---------------------------------------------------- self.xrf_spectrum_hwobj = None # Internal variables -------------------------------------------------- self.xrf_spectrum_model = queue_model_objects.XRFSpectrum() self._tree_view_item = None # Graphic elements ---------------------------------------------------- _top_widget = QWidget(self) _parameters_widget = QWidget(_top_widget) self.data_path_widget = DataPathWidget(_parameters_widget) self.other_parameters_gbox = QGroupBox("Other parameters", _parameters_widget) self.count_time_label = QLabel("Count time:", self.other_parameters_gbox) self.count_time_ledit = QLineEdit(self.other_parameters_gbox) self.count_time_ledit.setFixedWidth(50) self.adjust_transmission_cbox = QCheckBox("Adjust transmission", \ self.other_parameters_gbox) self.adjust_transmission_cbox.hide() self.mca_spectrum_widget = McaSpectrumWidget(self) self.snapshot_widget = SnapshotWidget(self) # Layout ------------------------------------------------------------- _other_parameters_gbox_hlayout = QHBoxLayout( self.other_parameters_gbox) _other_parameters_gbox_hlayout.addWidget(self.count_time_label) _other_parameters_gbox_hlayout.addWidget(self.count_time_ledit) _other_parameters_gbox_hlayout.addWidget(self.adjust_transmission_cbox) _other_parameters_gbox_hlayout.addStretch(0) _other_parameters_gbox_hlayout.setSpacing(2) _other_parameters_gbox_hlayout.setContentsMargins(0, 0, 0, 0) _parameters_widget_layout = QVBoxLayout(_parameters_widget) _parameters_widget_layout.addWidget(self.data_path_widget) _parameters_widget_layout.addWidget(self.other_parameters_gbox) _parameters_widget_layout.addStretch(0) _parameters_widget_layout.setSpacing(2) _parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _top_widget_layout = QHBoxLayout(_top_widget) _top_widget_layout.addWidget(_parameters_widget) _top_widget_layout.addWidget(self.snapshot_widget) _top_widget_layout.setSpacing(2) _top_widget_layout.addStretch(0) _top_widget_layout.setContentsMargins(0, 0, 0, 0) _main_vlayout = QVBoxLayout(self) _main_vlayout.addWidget(_top_widget) _main_vlayout.addWidget(self.mca_spectrum_widget) _main_vlayout.setSpacing(2) _main_vlayout.setContentsMargins(0, 0, 0, 0) # SizePolicies ------------------------------------------------------- self.mca_spectrum_widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) _top_widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) # Qt signal/slot connections ------------------------------------------ self.data_path_widget.data_path_layout.prefix_ledit.textChanged.\ connect(self._prefix_ledit_change) self.data_path_widget.data_path_layout.run_number_ledit.textChanged.\ connect(self._run_number_ledit_change) self.count_time_ledit.textChanged.connect(\ self._count_time_ledit_change) # Other --------------------------------------------------------------- def _prefix_ledit_change(self, new_value): self.xrf_spectrum_model.set_name(str(new_value)) self._tree_view_item.setText(\ 0, self.xrf_spectrum_model.get_display_name()) def _run_number_ledit_change(self, new_value): if str(new_value).isdigit(): self.xrf_spectrum_model.set_number(int(new_value)) self._tree_view_item.setText(\ 0, self.xrf_spectrum_model.get_display_name()) def _count_time_ledit_change(self, new_value): if str(new_value).isdigit(): self.xrf_spectrum_model.set_count_time(float(new_value)) def tab_changed(self): if self._tree_view_item: self.populate_widget(self._tree_view_item) def populate_widget(self, item): self._tree_view_item = item self.xrf_spectrum_model = item.get_model() executed = self.xrf_spectrum_model.is_executed() self.data_path_widget.setEnabled(not executed) self.other_parameters_gbox.setEnabled(not executed) #self.mca_spectrum_widget.setEnabled(executed) if executed: result = self.xrf_spectrum_model.get_spectrum_result() self.mca_spectrum_widget.set_data(result.mca_data, result.mca_calib, result.mca_config) else: self.mca_spectrum_widget.clear() self.data_path_widget.update_data_model(\ self.xrf_spectrum_model.path_template) self.count_time_ledit.setText(\ str(self.xrf_spectrum_model.count_time)) image = self.xrf_spectrum_model.centred_position.snapshot_image self.snapshot_widget.display_snapshot(image, width=400) def set_xrf_spectrum_hwobj(self, xrf_spectrum_hwobj): if self.xrf_spectrum_hwobj is None: self.xrf_spectrum_hwobj = xrf_spectrum_hwobj self.xrf_spectrum_hwobj.connect("xrfSpectrumFinished", self.spectrum_finished) def spectrum_finished(self, mca_data, mca_calib, mca_config): self.mca_spectrum_widget.set_data(mca_data, mca_calib, mca_config)
def __init__(self, parent = None, name = "xrf_scan_tab_widget"): QtGui.QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Hardware objects ---------------------------------------------------- self.xrf_scan_hwobj = None # Internal variables -------------------------------------------------- self.xrf_scan_model = queue_model_objects.XRFScan() self._tree_view_item = None # Graphic elements ---------------------------------------------------- _top_widget = QtGui.QWidget(self) _parameters_widget = QtGui.QWidget(_top_widget) self.data_path_widget = DataPathWidget(_parameters_widget) self.other_parameters_gbox = QtGui.QGroupBox("Other parameters", _parameters_widget) self.count_time_label = QtGui.QLabel("Count time:", self.other_parameters_gbox) self.count_time_ledit = QtGui.QLineEdit(self.other_parameters_gbox) self.count_time_ledit.setFixedWidth(50) self.position_widget = uic.loadUi(os.path.join(os.path.dirname(__file__), 'ui_files/Qt4_snapshot_widget_layout.ui')) self.mca_spectrum_widget = McaSpectrumWidget(self) # Layout ------------------------------------------------------------- self.other_parameters_gbox_layout = QtGui.QHBoxLayout(self) self.other_parameters_gbox_layout.addWidget(self.count_time_label) self.other_parameters_gbox_layout.addWidget(self.count_time_ledit) self.other_parameters_gbox_layout.addStretch(0) self.other_parameters_gbox_layout.setSpacing(2) self.other_parameters_gbox_layout.setContentsMargins(3, 3, 3, 3) self.other_parameters_gbox.setLayout(self.other_parameters_gbox_layout) _parameters_widget_layout = QtGui.QVBoxLayout() _parameters_widget_layout.addWidget(self.data_path_widget) _parameters_widget_layout.addWidget(self.other_parameters_gbox) _parameters_widget_layout.addStretch(0) _parameters_widget_layout.setSpacing(2) _parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _parameters_widget.setLayout(_parameters_widget_layout) _top_widget_layout = QtGui.QHBoxLayout(_top_widget) _top_widget_layout.addWidget(_parameters_widget) _top_widget_layout.addWidget(self.position_widget) _top_widget_layout.setSpacing(2) _top_widget_layout.setContentsMargins(0, 0, 0, 0) _top_widget.setLayout(_top_widget_layout) _main_vlayout = QtGui.QVBoxLayout(self) _main_vlayout.addWidget(_top_widget) _main_vlayout.addWidget(self.mca_spectrum_widget) _main_vlayout.setSpacing(2) _main_vlayout.setContentsMargins(0, 0, 0, 0) self.setLayout(_main_vlayout) # SizePolicies ------------------------------------------------------- self.position_widget.setFixedSize(457, 350) self.mca_spectrum_widget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) _top_widget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) #self.mca_spectrum_widget.setMinimumHeight(800) #self.setSizePolicy(QtGui.QSizePolicy.Expanding, # QtGui.QSizePolicy.Fixed) # Qt signal/slot connections ------------------------------------------ self.data_path_widget.data_path_layout.prefix_ledit.\ textChanged.connect(self._prefix_ledit_change) self.data_path_widget.data_path_layout.run_number_ledit.\ textChanged.connect(self._run_number_ledit_change) self.count_time_ledit.textChanged.connect(self._count_time_ledit_change) #QtCore.QObject.connect(.qApp, qt.PYSIGNAL('tab_changed'), # self.tab_changed) # Other --------------------------------------------------------------- Qt4_widget_colors.set_widget_color(self.other_parameters_gbox, Qt4_widget_colors.GROUP_BOX_GRAY) Qt4_widget_colors.set_widget_color(self.data_path_widget, Qt4_widget_colors.GROUP_BOX_GRAY) Qt4_widget_colors.set_widget_color(self.position_widget, Qt4_widget_colors.GROUP_BOX_GRAY)
def __init__(self, parent = None, name = "xrf_spectrum_parameters_widget"): QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Hardware objects ---------------------------------------------------- self.xrf_spectrum_hwobj = None # Internal variables -------------------------------------------------- self.xrf_spectrum_model = queue_model_objects.XRFSpectrum() self._tree_view_item = None # Graphic elements ---------------------------------------------------- _top_widget = QWidget(self) _parameters_widget = QWidget(_top_widget) self.data_path_widget = DataPathWidget(_parameters_widget) self.other_parameters_gbox = loadUi(os.path.join(os.path.dirname(__file__), "ui_files/Qt4_xrf_parameters_widget_layout.ui")) self.excitation_energy_ledit = self.other_parameters_gbox.excitation_energy_ledit self.count_time_ledit = self.other_parameters_gbox.count_time_ledit self.adjust_transmission_cbox = self.other_parameters_gbox.adjust_transmission_cbox self.mca_spectrum_widget = McaSpectrumWidget(self) self.snapshot_widget = SnapshotWidget(self) # Layout ------------------------------------------------------------- _parameters_widget_layout = QVBoxLayout(_parameters_widget) _parameters_widget_layout.addWidget(self.data_path_widget) _parameters_widget_layout.addWidget(self.other_parameters_gbox) _parameters_widget_layout.addStretch(0) _parameters_widget_layout.setSpacing(2) _parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _top_widget_layout = QHBoxLayout(_top_widget) _top_widget_layout.addWidget(_parameters_widget) _top_widget_layout.addWidget(self.snapshot_widget) _top_widget_layout.setSpacing(2) _top_widget_layout.addStretch(0) _top_widget_layout.setContentsMargins(0, 0, 0, 0) _main_vlayout = QVBoxLayout(self) _main_vlayout.addWidget(_top_widget) _main_vlayout.addWidget(self.mca_spectrum_widget) _main_vlayout.setSpacing(2) _main_vlayout.setContentsMargins(0, 0, 0, 0) # SizePolicies ------------------------------------------------------- self.mca_spectrum_widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) _top_widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) # Qt signal/slot connections ------------------------------------------ self.data_path_widget.data_path_layout.prefix_ledit.textChanged.\ connect(self._prefix_ledit_change) self.data_path_widget.data_path_layout.run_number_ledit.textChanged.\ connect(self._run_number_ledit_change) self.count_time_ledit.textChanged.connect(\ self._count_time_ledit_change) self.excitation_energy_ledit.textChanged.connect(\ self._excitation_energy_ledit_change)