def __init__(self, parent, client, **settings): QMainWindow.__init__(self, parent) self.client = client self.setWindowTitle(' ') # window title is unnecessary flags = self.windowFlags() flags |= Qt.WindowStaysOnTopHint flags ^= Qt.WindowMinimizeButtonHint self.setWindowFlags(flags) self.sgroup = SettingGroup('EstopTool') with self.sgroup as settings: self.restoreGeometry(settings.value('geometry', '', QByteArray)) icon = QIcon(':/estop') icon.addFile(':/estopdown', mode=QIcon.Active) self.btn = PicButton(icon, self) widget = QWidget(self) layout = QHBoxLayout() layout.addWidget(self.btn) layout.setContentsMargins(3, 3, 3, 3) widget.setLayout(layout) self.setCentralWidget(widget) self.btn.clicked.connect(self.dostop) self.setFixedSize(self.minimumSize()) self.show()
def __init__(self, parent, client, **configs): QDialog.__init__(self, parent) DlgUtils.__init__(self, self.toolName) loadUi(self, 'tools/downtime.ui') self.sendBtn = self.buttonBox.addButton('&Send', QDialogButtonBox.AcceptRole) self.sendBtn.setIcon(QIcon(':/mail')) self.sendBtn.setDisabled(True) self.parentwindow = parent self.client = client if hasattr(parent, 'mainwindow'): self.mainwindow = parent.mainwindow self.log = NicosLogger(self.toolName) self.log.parent = self.mainwindow.log else: self.log = configs.get('log', None) self.sgroup = SettingGroup(self.toolName) self._sender = configs.get('sender', '*****@*****.**') self._receiver = configs.get('receiver', '*****@*****.**') self._mailserver = configs.get('mailserver', '') or \ self._getDeviceComponent('experiment', 'mailserver', 'smtp.frm2.tum.de') self._instrument = configs.get('instrument', '') or \ self._getDeviceComponent('instrument', 'instrument', 'DEMO') t = self.mailheaderText.text().replace('{{instrument}}', self._instrument) self.mailheaderText.setText(t) self.startDown.setDateTime(QDateTime.currentDateTime().addSecs(-3600)) self.endDown.setDateTime(QDateTime.currentDateTime()) self.errorText.setVisible(False) with self.sgroup as settings: self.loadSettings(settings) self.reasons.clearEditText()
def __init__(self, parent, wintype, config): from nicos.clients.gui.panels.utils import createWindowItem QMainWindow.__init__(self, parent) loadUi(self, 'auxwindow.ui') self.mainwindow = parent self.client = parent.client self.log = NicosLogger('AuxiliaryWindow') self.log.parent = self.mainwindow.log self.type = wintype self.panels = [] self.splitters = [] self.sgroup = SettingGroup(config.name) with self.sgroup as settings: loadUserStyle(self, settings) self.setWindowTitle(config.name) widget = createWindowItem(config.contents, self, self, self, self.log) if widget: self.centralLayout.addWidget(widget) self.centralLayout.setContentsMargins(6, 6, 6, 6) with self.sgroup as settings: loadBasicWindowSettings(self, settings) if len(self.splitstate) == len(self.splitters): for sp, st in zip(self.splitters, self.splitstate): sp.restoreState(st) setups = config[1].get('setups', '') self.setSetups(setups) self.client.register(self, 'session/mastersetup') SetupDepWindowMixin.__init__(self, self.client)
def __init__(self, title, parent): self.tabIdx = -1 QMainWindow.__init__(self, parent) self.setWindowTitle(title) self.setWindowModality(Qt.NonModal) self.sgroup = SettingGroup(title) with self.sgroup as settings: loadBasicWindowSettings(self, settings)
def select(cls, reason='', force=False): with SettingGroup('Instrument') as settings: configfile = None if force else \ (settings.value('guiconfig') or None) while not (configfile and path.isfile(configfile)): dlg = cls(reason) result = dlg.exec_() if not result: return None items = dlg.confTree.selectedItems() if items: configfile = items[0].data(0, QTreeWidgetItem.UserType) if force or dlg.saveBox.isChecked(): settings.setValue('guiconfig', configfile) return configfile
def __init__(self, parent, client, options): QWidget.__init__(self, parent) self.log = NicosLogger(self.panelName) self.log.parent = parent.mainwindow.log SetupDepPanelMixin.__init__(self, client, options) DlgUtils.__init__(self, self.panelName) self.parentwindow = parent self.client = client self.mainwindow = parent.mainwindow self.actions = set() self.sgroup = SettingGroup(self.panelName) with self.sgroup as settings: self.loadSettings(settings) self.setProperty('type', 'Panel') self.setProperty('panel', self.__class__.__name__)
def createWindowContent(self): self.sgroup = SettingGroup('MainWindow') with self.sgroup as settings: loadUserStyle(self, settings) # load saved settings and stored layout for panel config self.loadSettings(settings) # create panels in the main window widget = createWindowItem(self.gui_conf.main_window, self, self, self, self.log) if widget: self.centralLayout.addWidget(widget) self.centralLayout.setContentsMargins(0, 0, 0, 0) # call postInit after creation of all panels for panel in self.panels: panel.postInit() with self.sgroup as settings: # geometry and window appearance loadBasicWindowSettings(self, settings) self.update() # load auxiliary windows state self.loadAuxWindows(settings) if len(self.splitstate) == len(self.splitters): for sp, st in zip(self.splitters, self.splitstate): sp.restoreState(st) if not self.gui_conf.windows: self.menuBar().removeAction(self.menuWindows.menuAction()) for i, wconfig in enumerate(self.gui_conf.windows): action = ToolAction(self.client, QIcon(':/' + wconfig.icon), wconfig.name, wconfig.options, self) self.toolBarWindows.addAction(action) self.menuWindows.addAction(action) def window_callback(on, i=i): self.createWindow(i) action.triggered[bool].connect(window_callback) if not self.gui_conf.windows: self.toolBarWindows.hide() else: self.toolBarWindows.show() createToolMenu(self, self.gui_conf.tools, self.menuTools) if isinstance(self.gui_conf.main_window, tabbed) and widget: widget.tabChangedTab(0)
def __init__(self): self._reconfiguring = False QMainWindow.__init__(self) # set app icon in multiple sizes icon = QIcon() icon.addFile(':/appicon') icon.addFile(':/appicon-16') icon.addFile(':/appicon-48') self.setWindowIcon(icon) self.keyChange.connect(lambda obj, args: obj.on_keyChange(*args)) self.reconfigure.connect(self.do_reconfigure) self.sgroup = SettingGroup('Monitor') with self.sgroup as settings: # geometry and window appearance loadBasicWindowSettings(self, settings)
def addPanel(self, widget, label): sgroup = SettingGroup(label) with sgroup as settings: detached = settings.value('detached', False, bool) index = len(self.tabIdx) self.tabIdx[index] = self.TabWidgetStorage(index, widget, label) if not detached: index = self.addTab(widget, label) if not label or label.isspace(): self.setTabEnabled(index, False) for i in self.tabIdx.values(): # search for it in the list of tabs if i.widget == widget: i.setDetached(None) else: detachWindow = DetachedWindow(label.replace('&', ''), self.parentWidget()) detachWindow.tabIdx = index detachWindow.setAttribute(Qt.WA_DeleteOnClose, True) self.tabIdx[index].setDetached(detachWindow) detachWindow.closed.connect(self.attachTab) panel = self._getPanel(widget) if panel and not isinstance(panel, QTabWidget): panel.setWidgetVisible.disconnect(self.setWidgetVisibleSlot) panel.setWidgetVisible.connect( detachWindow.setWidgetVisibleSlot) widget.setParent(detachWindow) self._moveMenuTools(widget) self._moveActions(widget, detachWindow) detachWindow.setWidget(widget) detachWindow.destroyed.connect(detachWindow.deleteLater) with sgroup as settings: detachWindow.restoreGeometry( settings.value('geometry', '', QByteArray)) detachWindow.show()
def on_clearConfigBtn_clicked(self): with SettingGroup('Instrument') as settings: settings.remove('guiconfig') self.showInfo('Default instrument GUI configuration has been cleared.')