def __init__(self, parent, client, options): LokiPanelBase.__init__(self, parent, client, options) loadUi(self, findResource('nicos_ess/loki/gui/ui_files/scriptbuilder.ui')) self.window = parent self.runBtn.setVisible(False) self.mapping = {} self.expertmode = self.mainwindow.expertmode self._cmdlet = self.sender() self._layout = self.frame.layout() self.index = self._layout.indexOf(self._cmdlet) self.initialise_connection_status_listeners() modules = options.get('modules', []) for module in modules: importString(module) # should register cmdlets for cmdlet in all_cmdlets: def callback(on, cmdlet=cmdlet): inst = cmdlet(self, self.client) inst.cmdletUp.connect(self.on_cmdletUp) inst.cmdletDown.connect(self.on_cmdletDown) inst.cmdletRemove.connect(self.on_cmdletRemove) self.runBtn.setVisible(True) self.frame.layout().insertWidget( self.frame.layout().count() - 2, inst) action = QAction(cmdlet.name, self) action.triggered.connect(callback) self.mapping.setdefault(cmdlet.category, []).append(action) for category in all_categories[::-1]: if category not in self.mapping: return toolbtn = QToolButton(self) toolbtn.setText(category) toolbtn.setPopupMode(QToolButton.InstantPopup) menu = QMenu(self) menu.addActions(self.mapping[category]) toolbtn.setMenu(menu) self.btnLayout.insertWidget(1, toolbtn)
def __init__(self, parent, client, options): Panel.__init__(self, parent, client, options) loadUi(self, self.ui) self.window = parent self.mapping = {} self.current_cmdlet = None self.expertmode = self.mainwindow.expertmode # collect values of all cmdlets that have been added # so that the common fields carry over to the next cmdlet self.value_collection = {} self.commandInput.history = self.cmdhistory self.commandInput.completion_callback = self.completeInput self.console = None client.initstatus.connect(self.on_client_initstatus) client.mode.connect(self.on_client_mode) client.simresult.connect(self.on_client_simresult) modules = options.get('modules', []) for module in modules: importString(module) # should register cmdlets for cmdlet in all_cmdlets: action = QAction(cmdlet.name, self) def callback(on, cmdlet=cmdlet): self.selectCmdlet(cmdlet) action.triggered.connect(callback) self.mapping.setdefault(cmdlet.category, []).append(action) for category in all_categories[::-1]: if category not in self.mapping: continue toolbtn = QToolButton(self) toolbtn.setText(category) toolbtn.setPopupMode(QToolButton.InstantPopup) menu = QMenu(self) menu.addActions(self.mapping[category]) toolbtn.setMenu(menu) self.btnLayout.insertWidget(1, toolbtn)