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_ess/loki/gui/ui_files/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) 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) self.frm.thickBox.setValidator(DoubleValidator(self)) if config is not None: configToFrame(self.frm, config) # Apply local customisations to the stylesheet self.setStyleSheet(ConfigEditDialog_QSS) if not config: self.frm.whatLbl.setText('New sample configuration')
def __init__(self, parent, client, options): Panel.__init__(self, parent, client, options) # make a vertical layout for 'ourself' self.vBoxLayout = QVBoxLayout(self) # make a buttonBox self.buttonBox = QDialogButtonBox(self.buttons, parent=self) self.buttonBox.setObjectName('buttonBox') # put buttonBox below main content self.vBoxLayout.addWidget(self.buttonBox) allButtons = 'Ok Open Save Cancel Close Discard Apply Reset '\ 'RestoreDefaults Help SaveAll Yes YesToAll No NoToAll '\ 'Abort Retry Ignore'.split() for btn_name in allButtons: btn = self.buttonBox.button(getattr(QDialogButtonBox, btn_name)) if btn: handler = getattr(self, 'on_buttonBox_%s_clicked' % btn_name, None) if not handler: # pylint: disable=function-redefined def handler(self=self, n=btn_name): self.showError('on_buttonBox_%s_clicked not ' 'implemented!' % n) btn.clicked.connect(handler)
class CustomButtonPanel(Panel): """Base class for custom instrument specific panels with a QDialogButtonBox at the lower right and some glue magic for fancy stuff... """ buttons = QDialogButtonBox.Close | QDialogButtonBox.Apply def __init__(self, parent, client, options): Panel.__init__(self, parent, client, options) # make a vertical layout for 'ourself' self.vBoxLayout = QVBoxLayout(self) # make a buttonBox self.buttonBox = QDialogButtonBox(self.buttons, parent=self) self.buttonBox.setObjectName('buttonBox') # put buttonBox below main content self.vBoxLayout.addWidget(self.buttonBox) allButtons = 'Ok Open Save Cancel Close Discard Apply Reset '\ 'RestoreDefaults Help SaveAll Yes YesToAll No NoToAll '\ 'Abort Retry Ignore'.split() for btn_name in allButtons: btn = self.buttonBox.button(getattr(QDialogButtonBox, btn_name)) if btn: handler = getattr(self, 'on_buttonBox_%s_clicked' % btn_name, None) if not handler: # pylint: disable=function-redefined def handler(self=self, n=btn_name): self.showError('on_buttonBox_%s_clicked not ' 'implemented!' % n) btn.clicked.connect(handler) def panelState(self): """returns current window state as obtained from the stack of parents""" obj = self while hasattr(obj, 'parent'): if isinstance(obj, AuxiliaryWindow): return "tab" elif isinstance(obj, DetachedWindow): return "detached" obj = obj.parent() return "main" def on_buttonBox_Close_clicked(self): self.closeWindow() def on_buttonBox_Ok_clicked(self): """OK = Apply + Close""" if hasattr(self, 'on_buttonBox_Apply_clicked'): self.on_buttonBox_Apply_clicked() self.on_buttonBox_Close_clicked()
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) 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 _queryDetails(self): dlg = QDialog(self) dlg.setWindowTitle('Login details for ticket tracker required') layout = QGridLayout() layout.addWidget( QLabel( 'Please enter details for the ticket tracker. ' 'You can contact the instrument control group ' 'for help.', dlg)) layout.addWidget(QLabel('Instrument name:', dlg)) instrBox = QLineEdit(self.instrument, dlg) instrBox.setEnabled(self.instrument != 'none') layout.addWidget(instrBox) noinstrBox = QCheckBox('No instrument', dlg) noinstrBox.setChecked(self.instrument == 'none') noinstrBox.toggled.connect(lambda c: instrBox.setEnabled(not c)) layout.addWidget(noinstrBox) layout.addWidget(QLabel('Username:'******'Password:'******'Login successful. Your API key has been stored ' 'for further reports.') settings = CompatSettings('nicos', 'secrets') settings.beginGroup('Redmine') if noinstrBox.isChecked(): self.instrument = 'none' else: self.instrument = instrBox.text() self.apikey = apikey self.username = userBox.text() settings.setValue('instrument', self.instrument) settings.setValue('apikey', self.apikey) settings.setValue('username', self.username) if not self.instrument or not self.apikey: return False self.titleLabel.setText( 'Submit a ticket for instrument "%s" (as user %s)' % (self.instrument, self.username)) return True