def __init__(self, parameter, parent=None): _ParameterWidget.__init__(self, parameter, parent) # Variables model = _LayerModel() self._material_class = Material # Actions act_add = QAction(getIcon("list-add"), "Add layer", self) act_remove = QAction(getIcon("list-remove"), "Remove layer", self) act_clean = QAction(getIcon('edit-clear'), "Clear", self) # Widgets self._cb_unit = UnitComboBox('m') self._cb_unit.setUnit('um') self._tbl_layers = QTableView() self._tbl_layers.setModel(model) self._tbl_layers.setItemDelegate(_LayerDelegate()) header = self._tbl_layers.horizontalHeader() header.setResizeMode(QHeaderView.Stretch) header.setStyleSheet('color: blue') self._tlb_layers = QToolBar() spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self._tlb_layers.addWidget(spacer) self._tlb_layers.addAction(act_add) self._tlb_layers.addAction(act_remove) self._tlb_layers.addAction(act_clean) # Layouts layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) sublayout = QHBoxLayout() sublayout.addStretch() sublayout.addWidget(QLabel('Thickness unit')) sublayout.addWidget(self._cb_unit) layout.addLayout(sublayout) layout.addWidget(self._tbl_layers) layout.addWidget(self._tlb_layers) self.setLayout(layout) # Signals self.valuesChanged.connect(self._onChanged) self.validationRequested.connect(self._onChanged) act_add.triggered.connect(self._onAdd) act_remove.triggered.connect(self._onRemove) act_clean.triggered.connect(self._onClear) self._tbl_layers.doubleClicked.connect(self._onDoubleClicked) model.dataChanged.connect(self.valuesChanged) model.rowsInserted.connect(self.valuesChanged) model.rowsRemoved.connect(self.valuesChanged) self.validationRequested.emit()
def _column1(runner, options): STATE_ICONS = \ {LocalRunner.STATE_QUEUED: getIcon('media-playback-pause'), LocalRunner.STATE_RUNNING: getIcon('media-playback-start'), LocalRunner.STATE_SIMULATED: getIcon('face-smile'), LocalRunner.STATE_ERROR: getIcon('face-sad')} try: return STATE_ICONS.get(runner.options_state(options)) except KeyError: return None
def _initToolbar(self): toolbar = super(_SaveableResultMixin, self)._initToolbar() # Actions act_copy = toolbar.addAction(getIcon('edit-copy'), 'Copy') act_save = toolbar.addAction(getIcon('document-save'), 'Save') # Signals act_copy.triggered.connect(self.copy) act_save.triggered.connect(self.save) return toolbar
def _initUI(self): # Variables self._widgets = {} tbl_model = self._LimitTableModel() # Widgets self._cb_limit = QComboBox() self._cb_limit.setModel(self._LimitComboBoxModel()) btn_limit_add = QPushButton() btn_limit_add.setIcon(getIcon("list-add")) self._tbl_limit = QTableView() self._tbl_limit.setModel(tbl_model) self._tbl_limit.setItemDelegate(self._LimitTableDelegate()) header = self._tbl_limit.horizontalHeader() header.setResizeMode(QHeaderView.Stretch) header.hide() policy = self._tbl_limit.sizePolicy() policy.setVerticalStretch(True) self._tbl_limit.setSizePolicy(policy) tlb_limit = QToolBar() spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) tlb_limit.addWidget(spacer) act_remove = tlb_limit.addAction(getIcon("list-remove"), "Remove limit") act_clear = tlb_limit.addAction(getIcon("edit-clear"), "Clear") # Layouts layout = _ExpandableOptionsWizardPage._initUI(self) sublayout = QHBoxLayout() sublayout.addWidget(self._cb_limit, 1) sublayout.addWidget(btn_limit_add) layout.addRow("Select", sublayout) layout.addRow(self._tbl_limit) layout.addRow(tlb_limit) # Signals btn_limit_add.released.connect(self._onLimitAdd) act_remove.triggered.connect(self._onLimitRemove) act_clear.triggered.connect(self._onLimitClear) self._tbl_limit.doubleClicked.connect(self._onLimitDoubleClicked) tbl_model.dataChanged.connect(self.valueChanged) tbl_model.rowsInserted.connect(self.valueChanged) tbl_model.rowsRemoved.connect(self.valueChanged) return layout
def _initUI(self): # Widgets self._cb_model_type = QComboBox() self._cb_model_type.setModel(self._ModelTypeComboBoxModel()) self._cb_model = QComboBox() self._cb_model.setModel(self._ModelComboBoxModel()) self._cb_model.setMaxVisibleItems(10) btn_model_add = QPushButton() btn_model_add.setIcon(getIcon("list-add")) self._tbl_model = ModelTableWidget() tlb_model = QToolBar() spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) tlb_model.addWidget(spacer) act_remove = tlb_model.addAction(getIcon("list-remove"), "Remove model") act_clear = tlb_model.addAction(getIcon("edit-clear"), "Clear") # Layouts layout = _ExpandableOptionsWizardPage._initUI(self) sublayout = QHBoxLayout() sublayout.addWidget(self._cb_model_type, 1) sublayout.addWidget(self._cb_model, 1) sublayout.addWidget(btn_model_add) layout.addRow("Select", sublayout) layout.addRow(self._tbl_model) layout.addRow(tlb_model) # Signals btn_model_add.released.connect(self._onModelAdd) act_remove.triggered.connect(self._onModelRemove) act_clear.triggered.connect(self._onModelClear) self._cb_model_type.currentIndexChanged.connect(self._onModelTypeChanged) self._tbl_model.dataChanged.connect(self.valueChanged) return layout
def _initToolbar(self): toolbar = NavigationToolbar(self._canvas, self.parent()) act_save = toolbar._actions['save_figure'] act_copy = QAction(getIcon('edit-copy'), 'Copy', toolbar) toolbar.insertAction(act_save, act_copy) # Signals act_save.triggered.disconnect(toolbar.save_figure) act_save.triggered.connect(self.save) act_copy.triggered.connect(self.copy) return toolbar
def __init__(self, parent=None): QDialog.__init__(self, parent) self.setWindowTitle('Runner') self.setMinimumWidth(750) # Runner self._runner = None self._running_timer = QTimer() self._running_timer.setInterval(500) # Widgets self._dlg_progress = QProgressDialog() self._dlg_progress.setRange(0, 100) self._dlg_progress.setModal(True) self._dlg_progress.hide() lbl_outputdir = QLabel("Output directory") self._txt_outputdir = DirBrowseWidget() max_workers = cpu_count() #@UndefinedVariable lbl_workers = QLabel('Number of workers') self._spn_workers = QSpinBox() self._spn_workers.setRange(1, max_workers) self._spn_workers.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) lbl_max_workers = QLabel('(max: %i)' % max_workers) self._chk_overwrite = QCheckBox("Overwrite existing results in output directory") self._chk_overwrite.setChecked(True) self._lbl_available = QLabel('Available') self._lst_available = QListView() self._lst_available.setModel(_AvailableOptionsListModel()) self._lst_available.setSelectionMode(QListView.SelectionMode.MultiSelection) tlb_available = QToolBar() spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) tlb_available.addWidget(spacer) act_open = tlb_available.addAction(getIcon("document-open"), "Open") act_open.setShortcut(QKeySequence.Open) tlb_available.addSeparator() act_remove = tlb_available.addAction(getIcon("list-remove"), "Remove") act_clear = tlb_available.addAction(getIcon("edit-clear"), "Clear") self._btn_addtoqueue = QPushButton(getIcon("go-next"), "") self._btn_addtoqueue.setToolTip("Add to queue") self._btn_addtoqueue.setEnabled(False) self._btn_addalltoqueue = QPushButton(getIcon("go-last"), "") self._btn_addalltoqueue.setToolTip("Add all to queue") self._btn_addalltoqueue.setEnabled(False) self._lbl_options = QLabel('Queued/Running/Completed') self._tbl_options = QTableView() self._tbl_options.setModel(_StateOptionsTableModel()) self._tbl_options.setItemDelegate(_StateOptionsItemDelegate()) self._tbl_options.setSelectionMode(QListView.SelectionMode.NoSelection) self._tbl_options.setColumnWidth(1, 60) self._tbl_options.setColumnWidth(2, 80) header = self._tbl_options.horizontalHeader() header.setResizeMode(0, QHeaderView.Interactive) header.setResizeMode(1, QHeaderView.Fixed) header.setResizeMode(2, QHeaderView.Fixed) header.setResizeMode(3, QHeaderView.Stretch) self._btn_start = QPushButton(getIcon("media-playback-start"), "Start") self._btn_cancel = QPushButton("Cancel") self._btn_cancel.setEnabled(False) self._btn_close = QPushButton("Close") self._btn_import = QPushButton("Import") self._btn_import.setEnabled(False) # Layouts layout = QVBoxLayout() sublayout = QGridLayout() sublayout.addWidget(lbl_outputdir, 0, 0) sublayout.addWidget(self._txt_outputdir, 0, 1) sublayout.addWidget(lbl_workers, 1, 0) subsublayout = QHBoxLayout() subsublayout.addWidget(self._spn_workers) subsublayout.addWidget(lbl_max_workers) sublayout.addLayout(subsublayout, 1, 1) layout.addLayout(sublayout) sublayout.addWidget(self._chk_overwrite, 2, 0, 1, 3) sublayout = QGridLayout() sublayout.setColumnStretch(0, 1) sublayout.setColumnStretch(2, 3) sublayout.addWidget(self._lbl_available, 0, 0) sublayout.addWidget(self._lst_available, 1, 0) sublayout.addWidget(tlb_available, 2, 0) subsublayout = QVBoxLayout() subsublayout.addStretch() subsublayout.addWidget(self._btn_addtoqueue) subsublayout.addWidget(self._btn_addalltoqueue) subsublayout.addStretch() sublayout.addLayout(subsublayout, 1, 1) sublayout.addWidget(self._lbl_options, 0, 2) sublayout.addWidget(self._tbl_options, 1, 2) layout.addLayout(sublayout) sublayout = QHBoxLayout() sublayout.addStretch() sublayout.addWidget(self._btn_import) sublayout.addWidget(self._btn_start) sublayout.addWidget(self._btn_cancel) sublayout.addWidget(self._btn_close) layout.addLayout(sublayout) self.setLayout(layout) # Signal self._running_timer.timeout.connect(self._onRunningTimer) act_open.triggered.connect(self._onOpen) act_remove.triggered.connect(self._onRemove) act_clear.triggered.connect(self._onClear) self._btn_addtoqueue.released.connect(self._onAddToQueue) self._btn_addalltoqueue.released.connect(self._onAddAllToQueue) self._btn_start.released.connect(self._onStart) self._btn_cancel.released.connect(self._onCancel) self._btn_close.released.connect(self._onClose) self._btn_import.released.connect(self._onImport) self.options_added.connect(self._onOptionsAdded) self.options_running.connect(self._onOptionsRunning) self.options_simulated.connect(self._onOptionsSimulated) self.options_error.connect(self._onOptionsError) self.results_error.connect(self._onResultsError) # Defaults settings = get_settings() section = settings.add_section('gui') if hasattr(section, 'outputdir'): self._txt_outputdir.setPath(section.outputdir) if hasattr(section, 'maxworkers'): self._spn_workers.setValue(int(section.maxworkers)) if hasattr(section, 'overwrite'): state = True if section.overwrite.lower() == 'true' else False self._chk_overwrite.setChecked(state)
def _initUI(self): # Variables self._parameter_getters = {} def _program_getter(options): programs = list(options.programs) if len(programs) == 1: return programs[0] else: return list(programs) self._parameter_getters['program'] = _program_getter options = self.options() for name, getter in iter_getters(options): values = np.array(getter(options), ndmin=1) if len(values) < 2: continue self._parameter_getters[name] = getter # Actions act_add_series = QAction(getIcon("list-add"), "Add series", self) act_remove_series = QAction(getIcon("list-remove"), "Remove series", self) act_clear_series = QAction(getIcon("edit-clear"), "Clear", self) # Widgets self._cb_result_key = QComboBox() self._cb_x_parameter = QComboBox() self._cb_x_parameter.addItems(list(self._parameter_getters.keys())) self._lst_series = QListView() self._lst_series.setModel(_SeriesModel()) tlb_series = QToolBar() spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) tlb_series.addWidget(spacer) tlb_series.addAction(act_add_series) tlb_series.addAction(act_remove_series) tlb_series.addAction(act_clear_series) self._chk_normalize = QCheckBox('Normalize series') # Layouts layout = _ResultsToolItem._initUI(self) layout.addRow("Result", self._cb_result_key) layout.addRow("X parameter", self._cb_x_parameter) layout.addRow("Series", self._lst_series) layout.addRow(tlb_series) layout.addRow(self._chk_normalize) # Signals act_add_series.triggered.connect(self._onAddSeries) act_remove_series.triggered.connect(self._onRemoveSeries) act_clear_series.triggered.connect(self._onClearSeries) self._lst_series.doubleClicked.connect(self._onSeriesDoubleClicked) self._cb_result_key.currentIndexChanged.connect(self._onResultKeyChanged) self._chk_normalize.stateChanged.connect(self.stateChanged) # Defaults keys = set() for container in self.results(): for key, result in container.items(): if not isinstance(result, _SummarizableResult): continue keys.add(key) self._cb_result_key.addItems(sorted(keys)) return layout
def _initUI(self): # Variables model_forcing = _InteractionForcingTableModel() # Actions act_add_forcing = QAction(getIcon("list-add"), "Add interaction forcing", self) act_remove_forcing = QAction(getIcon("list-remove"), "Remove interaction forcing", self) # Widgets self._lbl_elastic_scattering_c1 = QLabel('C1') self._lbl_elastic_scattering_c1.setStyleSheet("color: blue") self._txt_elastic_scattering_c1 = MultiNumericalLineEdit() self._txt_elastic_scattering_c1.setValidator(_ElasticScatteringValidator()) self._txt_elastic_scattering_c1.setValues([0.0]) self._lbl_elastic_scattering_c2 = QLabel('C2') self._lbl_elastic_scattering_c2.setStyleSheet("color: blue") self._txt_elastic_scattering_c2 = MultiNumericalLineEdit() self._txt_elastic_scattering_c2.setValidator(_ElasticScatteringValidator()) self._txt_elastic_scattering_c2.setValues([0.0]) self._lbl_cutoff_energy_inelastic = QLabel('Inelastic collisions') self._lbl_cutoff_energy_inelastic.setStyleSheet("color: blue") self._txt_cutoff_energy_inelastic = MultiNumericalLineEdit() self._txt_cutoff_energy_inelastic.setValidator(_CutoffEnergyValidator()) self._txt_cutoff_energy_inelastic.setValues([50.0]) self._cb_cutoff_energy_inelastic = UnitComboBox('eV') self._lbl_cutoff_energy_bremsstrahlung = QLabel('Bremsstrahlung emission') self._lbl_cutoff_energy_bremsstrahlung.setStyleSheet("color: blue") self._txt_cutoff_energy_bremsstrahlung = MultiNumericalLineEdit() self._txt_cutoff_energy_bremsstrahlung.setValidator(_CutoffEnergyValidator()) self._txt_cutoff_energy_bremsstrahlung.setValues([50.0]) self._cb_cutoff_energy_bremsstrahlung = UnitComboBox('eV') self._lbl_maximum_step_length = QLabel('Maximum step length') self._lbl_maximum_step_length.setStyleSheet("color: blue") self._txt_maximum_step_length = MultiNumericalLineEdit() self._txt_maximum_step_length.setValidator(_MaximumStepLengthValidator()) self._txt_maximum_step_length.setValues([1e15]) self._cb_maximum_step_length_unit = UnitComboBox('m') self._tbl_forcing = QTableView() self._tbl_forcing.setModel(model_forcing) self._tbl_forcing.setItemDelegate(_InteractionForcingDelegate()) header = self._tbl_forcing.horizontalHeader() header.setResizeMode(QHeaderView.Stretch) self._tlb_forcing = QToolBar() spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self._tlb_forcing.addWidget(spacer) self._tlb_forcing.addAction(act_add_forcing) self._tlb_forcing.addAction(act_remove_forcing) # Layouts layout = QHBoxLayout() layout.addLayout(_MaterialDialog._initUI(self), 1) frame = QFrame() frame.setFrameShape(QFrame.VLine) frame.setFrameShadow(QFrame.Sunken) layout.addWidget(frame) sublayout = QVBoxLayout() box_elastic_scattering = QGroupBox("Elastic scattering") boxlayout = QFormLayout() boxlayout.addRow(self._lbl_elastic_scattering_c1, self._txt_elastic_scattering_c1) boxlayout.addRow(self._lbl_elastic_scattering_c2, self._txt_elastic_scattering_c2) box_elastic_scattering.setLayout(boxlayout) sublayout.addWidget(box_elastic_scattering) box_cutoff_energy = QGroupBox("Cutoff energy") boxlayout = QFormLayout() boxsublayout = QHBoxLayout() boxsublayout.addWidget(self._txt_cutoff_energy_inelastic, 1) boxsublayout.addWidget(self._cb_cutoff_energy_inelastic) boxlayout.addRow(self._lbl_cutoff_energy_inelastic, boxsublayout) boxsublayout = QHBoxLayout() boxsublayout.addWidget(self._txt_cutoff_energy_bremsstrahlung, 1) boxsublayout.addWidget(self._cb_cutoff_energy_bremsstrahlung) boxlayout.addRow(self._lbl_cutoff_energy_bremsstrahlung, boxsublayout) box_cutoff_energy.setLayout(boxlayout) sublayout.addWidget(box_cutoff_energy) subsublayout = QFormLayout() subsubsublayout = QHBoxLayout() subsubsublayout.addWidget(self._txt_maximum_step_length, 1) subsubsublayout.addWidget(self._cb_maximum_step_length_unit) subsublayout.addRow(self._lbl_maximum_step_length, subsubsublayout) sublayout.addLayout(subsublayout) box_forcing = QGroupBox('Interaction forcing') boxlayout = QVBoxLayout() boxlayout.addWidget(self._tbl_forcing) boxlayout.addWidget(self._tlb_forcing) box_forcing.setLayout(boxlayout) sublayout.addWidget(box_forcing) sublayout.addStretch() layout.addLayout(sublayout, 1) # Signals self._txt_elastic_scattering_c1.textChanged.connect(self._onElasticScatteringC1Changed) self._txt_elastic_scattering_c2.textChanged.connect(self._onElasticScatteringC2Changed) self._txt_cutoff_energy_inelastic.textChanged.connect(self._onCutoffEnergyInelasticChanged) self._txt_cutoff_energy_bremsstrahlung.textChanged.connect(self._onCutoffEnergyBremsstrahlungChanged) self._txt_maximum_step_length.textChanged.connect(self._onMaximumStepLengthChanged) act_add_forcing.triggered.connect(self._onForcingAdd) act_remove_forcing.triggered.connect(self._onForcingRemove) return layout