def on_client_connected(self): self.detectors.clear() self.sampleenv.clear() default_flags = Qt.ItemIsUserCheckable | Qt.ItemIsSelectable | \ Qt.ItemIsEnabled # fill detectors detectors = self.client.getDeviceList( 'nicos.core.device.Measurable', exclude_class='nicos.devices.generic.detector.PassiveChannel') self._orig_detlist = self.client.eval('session.experiment.detlist', []) for detname in detectors: item = QListWidgetItem(detname, self.detectors) item.setFlags(default_flags) item.setCheckState(Qt.Checked if detname in self._orig_detlist else Qt.Unchecked) # fill environment envdevs = self.client.getDeviceList( 'nicos.core.device.Readable', exclude_class='nicos.core.device.Measurable') self._orig_envlist = self.client.eval('session.experiment.envlist', []) for devname in envdevs: item = QListWidgetItem(devname, self.sampleenv) item.setFlags(default_flags) item.setCheckState(Qt.Checked if devname in self._orig_envlist else Qt.Unchecked) if self.client.viewonly: self.buttonBox.setStandardButtons(QDialogButtonBox.Close) else: self.buttonBox.setStandardButtons(QDialogButtonBox.Apply | QDialogButtonBox.Close)
def modifyData(self): visible_curves = self.visibleCurves() # get input from the user: which curves should be modified how dlg = dialogFromUi(self, 'panels/modify.ui') def checkAll(): for i in range(dlg.list.count()): dlg.list.item(i).setCheckState(Qt.Checked) dlg.selectall.clicked.connect(checkAll) for i, descr in visible_curves: li = QListWidgetItem(descr, dlg.list) if len(visible_curves) == 1: li.setCheckState(Qt.Checked) dlg.operation.setFocus() else: li.setCheckState(Qt.Unchecked) if dlg.exec_() != QDialog.Accepted: return # evaluate selection op = dlg.operation.text() curves = [] for i in range(dlg.list.count()): li = dlg.list.item(i) if li.checkState() == Qt.Checked: curves.append(i) # modify curve data for i in curves: curve = self.plotcurves[visible_curves[i][0]] self._modifyCurve(curve, op) self.update()
def on_client_connected(self): # fill setups self._setupinfo = self.client.eval('session.readSetupInfo()', {}) all_loaded = self.client.eval('session.loaded_setups', set()) self._prev_aliases = self.client.eval( '{d.name: d.alias for d in session.devices.values() ' 'if "alias" in d.parameters}', {}) self._loaded = set() self._loaded_basic = None self.basicSetup.clear() self.optSetups.clear() self.errorLabel.hide() default_flags = Qt.ItemIsUserCheckable | Qt.ItemIsSelectable | \ Qt.ItemIsEnabled keep = QListWidgetItem('<keep current>', self.basicSetup) if self._setupinfo is not None: for name, info in sorted(self._setupinfo.items()): if info is None: self.errorLabel.show() continue if info['group'] == 'basic': QListWidgetItem(name, self.basicSetup) if name in all_loaded: self._loaded_basic = name self._loaded.add(name) elif info['group'] == 'optional': item = QListWidgetItem(name, self.optSetups) item.setFlags(default_flags) item.setData(Qt.UserRole, 0) if name in all_loaded: self._loaded.add(name) item.setCheckState(Qt.Checked if name in all_loaded else Qt.Unchecked) elif info['group'] == 'plugplay': item = QListWidgetItem(name, self.optSetups) item.setFlags(default_flags) item.setData(Qt.UserRole, 1) if name in all_loaded: self._loaded.add(name) elif not self.showPnpBox.isChecked(): item.setHidden(True) item.setCheckState(Qt.Checked if name in all_loaded else Qt.Unchecked) self.basicSetup.setCurrentItem(keep) self._prev_alias_config = self._alias_config if self.client.viewonly: self.buttonBox.setStandardButtons(QDialogButtonBox.Close) self.buttonBox.removeButton(self._reload_btn) else: self.buttonBox.setStandardButtons(QDialogButtonBox.Apply | QDialogButtonBox.Close) self.buttonBox.addButton(self._reload_btn, QDialogButtonBox.ResetRole)
def __init__(self, parent, client): Cmdlet.__init__(self, parent, client, findResource('nicos_mlz/kws3/gui/restore.ui')) for devname in self._getDeviceList(): item = QListWidgetItem(devname, self.devList) item.setCheckState(Qt.Unchecked)