def __init__(self, parent, client, instrument, configs, config=None): QDialog.__init__(self, parent) self.instrument = instrument self.configs = configs self.client = client self.setWindowTitle('Sample configuration') layout = QVBoxLayout() self.frm = QFrame(self) loadUi(self.frm, findResource('nicos_mlz/kws1/gui/sampleconf_one.ui')) self.frm.addDevBtn.clicked.connect(self.on_addDevBtn_clicked) self.frm.delDevBtn.clicked.connect(self.on_delDevBtn_clicked) self.frm.readDevsBtn.clicked.connect(self.on_readDevsBtn_clicked) self.frm.readApBtn.clicked.connect(self.on_readApBtn_clicked) self.frm.nameBox.setValidator( QRegExpValidator(QRegExp(r'[A-Za-z0-9.,=+-]{1,20}'), self)) box = QDialogButtonBox(self) box.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) box.accepted.connect(self.maybeAccept) box.rejected.connect(self.reject) layout.addWidget(self.frm) layout.addWidget(box) self.setLayout(layout) for box in [ self.frm.offsetBox, self.frm.thickBox, self.frm.factorBox, self.frm.apXBox, self.frm.apYBox, self.frm.apWBox, self.frm.apHBox ]: box.setValidator(DoubleValidator(self)) if config is not None: configToFrame(self.frm, config)
def __init__(self, parent, history=None): HistoryLineEdit.__init__(self, parent, history) self.textChanged.connect(self.on_textChanged) self.returnPressed.connect(self.on_returnPressed) self.setValidator(QRegExpValidator(QRegExp(r"^\S.*"), self)) self.current_status = None self.error_status = None
def occur(self, what, regex=False): content = self.toPlainText().split('\n') if regex: regexp = QRegExp(what, Qt.CaseInsensitive) content = [line for line in content if regexp.indexIn(line) >= 0] else: what = what.lower() content = [line for line in content if what in line.lower()] content = '\n'.join(content) window = QMainWindow(self) window.resize(600, 800) window.setWindowTitle('Lines matching %r' % what) widget = QTextEdit(window) widget.setFont(self.font()) window.setCentralWidget(widget) widget.setText(content) window.show()
def on_filter_editTextChanged(self, text): for i in range(self.filter.count()): if text == self.filter.itemText(i): rx = QRegExp(self.filter.itemData(i)) break else: rx = QRegExp(text) for i in range(self.tree.topLevelItemCount()): setupitem = self.tree.topLevelItem(i) all_children_hidden = True for j in range(setupitem.childCount()): devitem = setupitem.child(j) if rx.indexIn(devitem.text(0)) == -1: devitem.setHidden(True) else: devitem.setHidden(False) all_children_hidden = False setupitem.setHidden(all_children_hidden)
def findNext(self, what, regex=False): cursor = self.textCursor() if regex: rx = QRegExp(what, Qt.CaseInsensitive) newcurs = self.document().find(rx, cursor) else: newcurs = self.document().find(what, cursor) self.setTextCursor(newcurs) return not newcurs.isNull()
def __init__(self, instruments, instrument=None, parent=None): QDialog.__init__(self, parent) uic.loadUi( path.abspath( path.join(path.dirname(__file__), '..', 'ui', 'dialogs', 'newsetupdialog.ui')), self) self.setInstruments(instruments) if instrument: self.setCurrentInstrument(instrument) self.comboBoxInstrument.setDisabled(True) self.lineEditFileName.setValidator( QRegExpValidator(QRegExp('[A-Za-z_]{1}[A-Za-z0-9_]*')))
def __init__(self, parent, client, options): GenericPanel.__init__(self, parent, client, options) for ch in self.findChildren(NicosWidget): ch.setClient(client) # daemon request ID of last command executed from this panel # (used to display messages from this command) self._current_status = 'idle' self._exec_reqid = None self._error_window = None self.motor_widgets = { 'som': self.somEdit, 's2t': self.s2tEdit, 'soz': self.sozEdit, 'stz': self.stzEdit } self.slit_widgets = { 'slit1_opening': self.slit1Edit, 'slit2_opening': self.slit2Edit, 'slit3_opening': self.slit3Edit, 'slit4_opening': self.slit4Edit, 'd5v': self.slit5Edit, } self.magnet_widgets = { 'hsy': self.hsyEdit } # Initialise the widgets self._reinit() # Set the validator for monitor preset edit # Regular expression for scientific notation: [\d.]+(?:e\d+)? self.monitorPresetBox.setValidator( QRegExpValidator(QRegExp(r"[\d.]+(?:e\d+)?"), self)) self.setMonitorPreset(True) self.setSampleMove(True) self.opMonitor.toggled.connect(self.setMonitorPreset) self.opTime.toggled.connect(self.setTimePreset) self.opSampleMove.toggled.connect(self.setSampleMove) self.opSampleSetPosition.toggled.connect(self.setSampleSetPosition) client.message.connect(self.on_client_message) client.setup.connect(self.on_client_setup)
def __init__(self, classesList, parent=None): QDialog.__init__(self, parent) uic.loadUi( path.abspath( path.join(path.dirname(__file__), '..', 'ui', 'dialogs', 'newdevicedialog.ui')), self) self.menu = QMenu('Select class') self.pushButtonSelectClass.setMenu(self.menu) for _class in sorted([str(__class)[14:-2] for __class in classesList]): self.recursiveMenu(_class, self.menu) self.menuCustom = QMenu('Select class') for _class in sorted([ str(__class)[14:-2] for __class in classparser.getDeviceClasses(None) ]): self.recursiveMenu(_class, self.menuCustom) self.checkBoxCustomClasses.stateChanged.connect( self.stateChangedHandler) self.lineEditDeviceName.setValidator( QRegExpValidator(QRegExp('[A-Za-z0-9_]*')))