def __init__(self, parent, client, options): Panel.__init__(self, parent, client, options) loadUi(self, findResource('nicos_mlz/kws1/gui/sampleconf.ui')) self.sampleGroup.setEnabled(False) self.frame.setLayout(QVBoxLayout()) menu = QMenu(self) menu.addAction(self.actionCopyAperture) menu.addAction(self.actionCopyDetOffset) menu.addAction(self.actionCopyThickness) menu.addAction(self.actionCopyTimeFactor) menu.addSeparator() menu.addAction(self.actionCopyAll) self.copyBtn.setMenu(menu) menu = QMenu(self) menu.addAction(self.actionEmpty) menu.addAction(self.actionGenerate) self.createBtn.setMenu(menu) self.configs = [] self.dirty = False self.filename = None self.holder_info = options.get('holder_info', []) self.instrument = options.get('instrument', 'kws1')
def getMenus(self): if not self.menus: menu1 = QMenu('&Data plot', self) menu1.addAction(self.actionSavePlot) menu1.addAction(self.actionPrint) menu1.addAction(self.actionAttachElog) menu1.addSeparator() menu1.addAction(self.actionResetPlot) menu1.addAction(self.actionAutoDisplay) menu1.addAction(self.actionCombine) menu1.addAction(self.actionClosePlot) menu1.addAction(self.actionDeletePlot) menu1.addSeparator() menu1.addAction(self.actionXAxis) menu1.addAction(self.actionYAxis) menu1.addAction(self.actionNormalized) menu1.addSeparator() menu1.addAction(self.actionUnzoom) menu1.addAction(self.actionLogXScale) menu1.addAction(self.actionLogScale) menu1.addAction(self.actionAutoScale) menu1.addAction(self.actionScaleX) menu1.addAction(self.actionScaleY) menu1.addAction(self.actionLegend) menu1.addAction(self.actionErrors) menu1.addSeparator() menu2 = QMenu('Data &manipulation', self) menu2.addAction(self.actionModifyData) menu2.addSeparator() ag = QActionGroup(menu2) ag.addAction(self.actionFitPeakGaussian) ag.addAction(self.actionFitPeakLorentzian) ag.addAction(self.actionFitPeakPV) ag.addAction(self.actionFitPeakPVII) ag.addAction(self.actionFitTc) ag.addAction(self.actionFitCosine) ag.addAction(self.actionFitSigmoid) ag.addAction(self.actionFitLinear) ag.addAction(self.actionFitExponential) menu2.addAction(self.actionFitPeak) menu2.addAction(self.actionPickInitial) menu2.addAction(self.actionFitPeakGaussian) menu2.addAction(self.actionFitPeakLorentzian) menu2.addAction(self.actionFitPeakPV) menu2.addAction(self.actionFitPeakPVII) menu2.addAction(self.actionFitTc) menu2.addAction(self.actionFitCosine) menu2.addAction(self.actionFitSigmoid) menu2.addAction(self.actionFitLinear) menu2.addAction(self.actionFitExponential) menu2.addSeparator() menu2.addAction(self.actionFitArby) self.menus = [menu1, menu2] return self.menus
def _refresh_presets(self): pmenu = self.presetmenu pmenu.clear() delmenu = QMenu('Delete', self) try: for preset, info in iteritems(self.presetdict): paction = QAction(preset, self) pdelaction = QAction(preset, self) info = info.copy() def launchpreset(on, info=info): self._createViewFromDialog(info) def delpreset(on, name=preset, act=paction, delact=pdelaction): pmenu.removeAction(act) delmenu.removeAction(delact) self.presetdict.pop(name, None) self._refresh_presets() paction.triggered[bool].connect(launchpreset) pmenu.addAction(paction) pdelaction.triggered[bool].connect(delpreset) delmenu.addAction(pdelaction) except AttributeError: self.presetdict = {} if self.presetdict: pmenu.addSeparator() pmenu.addMenu(delmenu) else: pmenu.addAction('(no presets created)')
def on_tableWidget_customContextMenuRequested(self, point): """Show context menu for adding and deleting echotimes (rows).""" self._stop_edit() menu = QMenu(self) add = menu.addAction('Add echo time') delete = menu.addAction('Delete echo time') row = self.tableWidget.rowAt(point.y()) # Disable the delete action if there is nothing to delete if row == -1: delete.setEnabled(False) sender = self.sender() # The Signal can be sent from the table widget itself or from the # vertical header. In case of the table widget, its viewport hast to be # used for correct placement of the context mneu if hasattr(sender, 'viewport'): sender = sender.viewport() action = menu.exec_(sender.mapToGlobal(point)) if action == add: self._add_row(row) elif action == delete: self._delete_row(row)
def __init__(self, parent, client, options): LokiPanelBase.__init__(self, parent, client, options) loadUi(self, findResource('nicos_ess/loki/gui/ui_files/sampleconf.ui')) self.sampleGroup.setEnabled(False) self.frame.setLayout(QVBoxLayout()) self.sample_frame = QFrame(self) loadUi( self.sample_frame, findResource('nicos_ess/loki/gui/ui_files/sampleconf_summary.ui')) layout = self.frame.layout() layout.addWidget(self.sample_frame) self.sample_frame.hide() self.sample_frame.posTbl.setEnabled(False) for box in self.sample_frame.findChildren(QLineEdit): box.setEnabled(False) menu = QMenu(self) menu.addAction(self.actionEmpty) menu.addAction(self.actionGenerate) self.createBtn.setMenu(menu) self.configs = [] self.holder_info = options.get('holder_info', []) self.instrument = options.get('instrument', 'loki') self.unapplied_changes = False self.applyBtn.setEnabled(False) self.initialise_connection_status_listeners()
def getMenus(self): if not self.menus: menu1 = QMenu('&Browser', self) menu1.addAction(self.actionBack) menu1.addAction(self.actionForward) menu1.addSeparator() menu1.addAction(self.actionRefresh) menu1.addAction(self.actionPrint) menu2 = QMenu('&Logbook', self) menu2.addAction(self.actionAddComment) menu2.addAction(self.actionAddRemark) menu2.addSeparator() menu2.addAction(self.actionAttachFile) menu2.addSeparator() menu2.addAction(self.actionNewSample) self.menus = [menu1, menu2] return self.menus
def getMenus(self): if not self.menu: menu = QMenu('&Live data', self) menu.addAction(self.actionPrint) menu.addSeparator() menu.addAction(self.actionUnzoom) menu.addAction(self.actionLogScale) self.menu = menu return [self.menu]
def initLiveWidget(self, widgetcls): if isinstance(self.widget, widgetcls): return # delete the old widget if self.widget: self.widgetLayout.removeWidget(self.widget) self.widget.deleteLater() # create a new one self.widget = widgetcls(self) # enable/disable controls and set defaults for new livewidget instances self.setControlsEnabled(True) if isinstance(self.widget, LiveWidget1D): self.set2DControlsEnabled(False) else: self.set2DControlsEnabled(True) # apply current global settings self.widget.setCenterMark(self.actionMarkCenter.isChecked()) self.widget.logscale(self.actionLogScale.isChecked()) if isinstance(self.widget, LiveWidget1D): self.widget.setSymbols(self.actionSymbols.isChecked()) self.widget.setLines(self.actionLines.isChecked()) # liveonly mode does not display a status bar if self._liveOnlyIndex is None: self.widget.gr.cbm.addHandler(MouseEvent.MOUSE_MOVE, self.on_mousemove_gr) # handle menus self.menuColormap = QMenu(self) self.actionsColormap = QActionGroup(self) activeMap = self.widget.getColormap() activeCaption = None for name, value in COLORMAPS.items(): caption = name.title() action = self.menuColormap.addAction(caption) action.setData(caption) action.setCheckable(True) if activeMap == value: action.setChecked(True) # update toolButton text later otherwise this may fail # depending on the setup and qt versions in use activeCaption = caption self.actionsColormap.addAction(action) action.triggered.connect(self.on_colormap_triggered) self.actionColormap.setMenu(self.menuColormap) # finish initiation self.widgetLayout.addWidget(self.widget) if activeCaption: self.toolbar.widgetForAction( self.actionColormap).setText(activeCaption) detectors = self.client.eval('session.experiment.detectors', []) self._register_rois(detectors)
def getMenus(self): menuFile = QMenu('&File', self) menuFile.addAction(self.actionNew) menuFile.addAction(self.actionOpen) menuFile.addAction(self.menuRecent.menuAction()) menuFile.addAction(self.actionSave) menuFile.addAction(self.actionSaveAs) menuFile.addAction(self.actionReload) menuFile.addSeparator() menuFile.addAction(self.actionPrint) menuView = QMenu('&View', self) menuView.addAction(self.actionShowScripts) menuEdit = QMenu('&Edit', self) menuEdit.addAction(self.actionUndo) menuEdit.addAction(self.actionRedo) menuEdit.addSeparator() menuEdit.addAction(self.actionCut) menuEdit.addAction(self.actionCopy) menuEdit.addAction(self.actionPaste) menuEdit.addSeparator() menuEdit.addAction(self.actionComment) menuEdit.addSeparator() menuEdit.addAction(self.actionFind) menuScript = QMenu('&Script', self) menuScript.addSeparator() menuScript.addAction(self.actionRun) menuScript.addAction(self.actionSimulate) menuScript.addAction(self.actionUpdate) menuScript.addSeparator() menuScript.addAction(self.actionGet) if self.toolconfig: menuTools = QMenu('Editor t&ools', self) createToolMenu(self, self.toolconfig, menuTools) menus = [menuFile, menuView, menuEdit, menuScript, menuTools] else: menus = [menuFile, menuView, menuEdit, menuScript] self.menus = menus return self.menus
def contextMenuOnItem(self, item, pos): if item is None: return # invoked context menu on whitespace if item.type() == ItemTypes.Setup: menu = QMenu(self) addDeviceAction = menu.addAction('Add device...') addDeviceAction.triggered.connect(self.addDevice) menu.popup(pos) elif item.type() == ItemTypes.Directory: menu = QMenu(self) addSetupAction = menu.addAction('Add setup...') addSetupAction.triggered.connect(self.addSetup) menu.popup(pos) elif item.type() == ItemTypes.Device: menu = QMenu(self) removeDeviceAction = menu.addAction('Remove') removeDeviceAction.triggered.connect(self.removeDevice) menu.popup(pos)
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_]*')))
def getMenus(self): self.menu = menu = QMenu('&Live data', self) menu.addAction(self.actionLoadTOF) menu.addAction(self.actionLoadPAD) menu.addSeparator() menu.addAction(self.actionWriteXml) menu.addAction(self.actionPrint) menu.addSeparator() menu.addAction(self.actionSetAsROI) menu.addAction(self.actionUnzoom) menu.addAction(self.actionLogScale) menu.addAction(self.actionNormalized) menu.addAction(self.actionLegend) return [menu]
def getMenus(self): if not self.menu: menu = QMenu('&Live data', self) menu.addAction(self.actionOpen) menu.addAction(self.actionPrint) menu.addSeparator() menu.addAction(self.actionKeepRatio) menu.addAction(self.actionUnzoom) menu.addAction(self.actionLogScale) menu.addAction(self.actionColormap) menu.addAction(self.actionMarkCenter) menu.addAction(self.actionROI) self.menu = menu return [self.menu]
def getMenus(self): menu = QMenu('&History viewer', self) menu.addAction(self.actionNew) menu.addSeparator() menu.addAction(self.actionSavePlot) menu.addAction(self.actionPrint) menu.addAction(self.actionAttachElog) menu.addAction(self.actionSaveData) menu.addSeparator() menu.addAction(self.actionEditView) menu.addAction(self.actionCloseView) menu.addAction(self.actionDeleteView) menu.addAction(self.actionResetView) menu.addSeparator() menu.addAction(self.actionLogScale) menu.addAction(self.actionAutoScale) menu.addAction(self.actionScaleX) menu.addAction(self.actionScaleY) menu.addAction(self.actionUnzoom) menu.addAction(self.actionLegend) menu.addAction(self.actionSymbols) menu.addAction(self.actionLines) ag = QActionGroup(menu) ag.addAction(self.actionFitPeakGaussian) ag.addAction(self.actionFitPeakLorentzian) ag.addAction(self.actionFitPeakPV) ag.addAction(self.actionFitPeakPVII) ag.addAction(self.actionFitTc) ag.addAction(self.actionFitCosine) ag.addAction(self.actionFitSigmoid) ag.addAction(self.actionFitLinear) ag.addAction(self.actionFitExponential) menu.addAction(self.actionFitPeak) menu.addAction(self.actionPickInitial) menu.addAction(self.actionFitPeakGaussian) menu.addAction(self.actionFitPeakLorentzian) menu.addAction(self.actionFitPeakPV) menu.addAction(self.actionFitPeakPVII) menu.addAction(self.actionFitTc) menu.addAction(self.actionFitCosine) menu.addAction(self.actionFitSigmoid) menu.addAction(self.actionFitLinear) menu.addAction(self.actionFitExponential) menu.addSeparator() menu.addAction(self.actionFitArby) menu.addSeparator() menu.addAction(self.actionClose) self._refresh_presets() return [menu, self.presetmenu]
def contextMenuOnItem(self, item, pos): if item is None: return # invoked context menu on whitespace topLevelItems = [] currentIndex = 0 while currentIndex < self.topLevelItemCount(): topLevelItems.append(self.topLevelItem(currentIndex)) currentIndex += 1 if self.currentItem() in topLevelItems: if self.currentItem().text(0) in self.nonListItems: if self.currentItem().childCount() > 0: return # value is already set, can't add multiple values menu = QMenu(self) addValueAction = menu.addAction('Add value...') addValueAction.triggered.connect(self.addValue) menu.popup(pos)
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 on_paramList_customContextMenuRequested(self, pos): item = self.paramList.itemAt(pos) if not item: return menu = QMenu(self) refreshAction = menu.addAction('Refresh') menu.addAction('Refresh all') # QCursor.pos is more reliable then the given pos action = menu.exec_(QCursor.pos()) if action: cmd = 'session.getDevice(%r).pollParams(volatile_only=False%s)' \ % (self.devname, ', param_list=[%r]' % item.text(0) if action == refreshAction else '') # poll even non volatile parameter as requested explicitely self.client.eval(cmd, None)
def on_roiItemClicked(self, event): if event.getButtons() & MouseEvent.RIGHT_BUTTON: if isinstance(event.roi.reference, FitResult): menu = QMenu(self) actionClipboard = QAction("Copy fit values to clipboard", menu) menu.addAction(actionClipboard) p0dc = event.getDC() selectedItem = menu.exec_( self.mapToGlobal(QPoint(p0dc.x, p0dc.y))) if selectedItem == actionClipboard: res = event.roi.reference text = '\n'.join( (n + '\t' if n else '\t') + (v + '\t' if isinstance(v, string_types) else '%g\t' % v) + (dv if isinstance(dv, string_types) else '%g' % dv) for (n, v, dv) in res.label_contents) QApplication.clipboard().setText(text)
def __init__(self, parent, client, options): Panel.__init__(self, parent, client, options) loadUi(self, self.ui) self.commandInput.scrollWidget = self.outView self.grepPanel.hide() self.grepText.scrollWidget = self.outView self.actionLabel.hide() self.outView.setActionLabel(self.actionLabel) self.commandInput.history = self.cmdhistory self.commandInput.completion_callback = self.completeInput self.grepNoMatch.setVisible(False) self.actionAllowLineWrap.setChecked(self.mainwindow.allowoutputlinewrap) client.connected.connect(self.on_client_connected) client.message.connect(self.on_client_message) client.simmessage.connect(self.on_client_simmessage) client.initstatus.connect(self.on_client_initstatus) client.mode.connect(self.on_client_mode) client.experiment.connect(self.on_client_experiment) self.outView.setContextMenuPolicy(Qt.CustomContextMenu) self.menu = QMenu('&Output', self) self.menu.addAction(self.actionCopy) self.menu.addAction(self.actionGrep) self.menu.addSeparator() self.menu.addAction(self.actionSave) self.menu.addAction(self.actionPrint) self.menu.addSeparator() self.menu.addAction(self.actionAllowLineWrap) self.on_actionAllowLineWrap_triggered( self.mainwindow.allowoutputlinewrap) self.hasinput = bool(options.get('hasinput', True)) self.inputFrame.setVisible(self.hasinput) self.hasmenu = bool(options.get('hasmenu', True)) if options.get('fulltime', False): self.outView.setFullTimestamps(True) watermark = options.get('watermark', '') if watermark: watermark = findResource(watermark) if path.isfile(watermark): self.outView.setBackgroundImage(watermark)
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)
def initLiveWidget(self, widgetcls): if isinstance(self.widget, widgetcls): return if self.widget: self.widgetLayout.removeWidget(self.widget) self.widget.deleteLater() self.widget = widgetcls(self) # enable/disable controls and set defaults for new livewidget instances self.setControlsEnabled(True) if isinstance(self.widget, LiveWidget1D): self.set2DControlsEnabled(False) else: self.set2DControlsEnabled(True) # apply current settings self.widget.setCenterMark(self.actionMarkCenter.isChecked()) self.widget.logscale(self.actionLogScale.isChecked()) guiConn = GUIConnector(self.widget.gr) guiConn.connect(MouseEvent.MOUSE_MOVE, self.on_mousemove_gr) self.menuColormap = QMenu(self) self.actionsColormap = QActionGroup(self) activeMap = self.widget.getColormap() activeCaption = None for name, value in iteritems(COLORMAPS): caption = name.title() action = self.menuColormap.addAction(caption) action.setData(caption) action.setCheckable(True) if activeMap == value: action.setChecked(True) # update toolButton text later otherwise this may fail # depending on the setup and qt versions in use activeCaption = caption self.actionsColormap.addAction(action) action.triggered.connect(self.on_colormap_triggered) self.actionColormap.setMenu(self.menuColormap) self.widgetLayout.addWidget(self.widget) if activeCaption: self.toolbar.widgetForAction( self.actionColormap).setText(activeCaption) detectors = self.client.eval('session.experiment.detectors', []) self._register_rois(detectors)
def __init__(self, log, gui_conf, viewonly=False, tunnel=''): DefaultMainWindow.__init__(self, log, gui_conf, viewonly, tunnel) self.addLogo() self.addInstrument() self.addExperiment() self.set_icons() self.stylefile = gui_conf.stylefile # Cheesburger menu dropdown = QMenu('') dropdown.addAction(self.actionConnect) dropdown.addAction(self.actionViewOnly) dropdown.addAction(self.actionPreferences) dropdown.addAction(self.actionExpert) dropdown.addSeparator() dropdown.addAction(self.actionExit) self.actionUser.setMenu(dropdown) self.actionUser.setIconVisibleInMenu(True) self.dropdown = dropdown
def getMenus(self): if self._liveOnlyIndex is not None: return [] if not self.menu: menu = QMenu('&Live data', self) menu.addAction(self.actionOpen) menu.addAction(self.actionPrint) menu.addAction(self.actionSavePlot) menu.addSeparator() menu.addAction(self.actionKeepRatio) menu.addAction(self.actionUnzoom) menu.addAction(self.actionLogScale) menu.addAction(self.actionColormap) menu.addAction(self.actionMarkCenter) menu.addAction(self.actionROI) menu.addAction(self.actionSymbols) menu.addAction(self.actionLines) self.menu = menu return [self.menu]
def __init__(self, log, gui_conf, viewonly=False, tunnel=''): DefaultMainWindow.__init__(self, log, gui_conf, viewonly, tunnel) self.add_logo() self.set_icons() self.style_file = gui_conf.stylefile # Cheeseburger menu dropdown = QMenu('') dropdown.addAction(self.actionConnect) dropdown.addAction(self.actionViewOnly) dropdown.addAction(self.actionPreferences) dropdown.addAction(self.actionExpert) dropdown.addSeparator() dropdown.addAction(self.actionExit) self.actionUser.setMenu(dropdown) self.actionUser.setIconVisibleInMenu(True) self.dropdown = dropdown self.actionExpert.setEnabled(self.client.isconnected) self.actionEmergencyStop.setEnabled(self.client.isconnected) self._init_instrument_name() self._init_experiment_name()
def recursiveMenu(self, partialString, parentMenu): if len(partialString.split('.')) == 1: action = parentMenu.addAction(partialString) action.triggered.connect(self.classSelectedSlot) else: uncombinedNextPartialString = partialString.split('.') menus = parentMenu.findChildren(QMenu) submenuIsPresent = False submenu = None for menu in menus: if menu.title() == uncombinedNextPartialString[0]: submenu = menu uncombinedNextPartialString.pop(0) submenuIsPresent = True if not submenuIsPresent: submenu = QMenu(uncombinedNextPartialString.pop(0), parentMenu) parentMenu.addMenu(submenu) nextPartialString = '.'.join(uncombinedNextPartialString) self.recursiveMenu(nextPartialString, submenu)
def _register_rois(self, detectors): self.rois.clear() self.actionROI.setVisible(False) self.menuROI = QMenu(self) self.actionsROI = QActionGroup(self) self.actionsROI.setExclusive(False) for detname in detectors: self.log.debug('checking rois for detector \'%s\'', detname) for tup in self.client.eval(detname + '.postprocess', ''): roi = tup[0] cachekey = roi + '/roi' # check whether or not this is a roi (cachekey exists). keyval = self.client.getCacheKey(cachekey) if keyval: self.on_roiChange(cachekey, keyval[1]) self.log.debug('register roi: %s', roi) # create roi menu action = self.menuROI.addAction(roi) action.setData(roi) action.setCheckable(True) self.actionsROI.addAction(action) action.triggered.connect(self.on_roi_triggered) self.actionROI.setMenu(self.menuROI) self.actionROI.setVisible(True)
def _show_context_menu(self): menu = QMenu() copy_action = QAction("Copy", self) copy_action.triggered.connect(self._handle_copy_cells) copy_action.setIcon(get_icon("file_copy-24px.svg")) menu.addAction(copy_action) cut_action = QAction("Cut", self) cut_action.triggered.connect(self._handle_cut_cells) cut_action.setIcon(get_icon("cut_24px.svg")) menu.addAction(cut_action) paste_action = QAction("Paste", self) paste_action.triggered.connect(self._handle_table_paste) paste_action.setIcon(get_icon("paste_24px.svg")) menu.addAction(paste_action) delete_action = QAction("Delete", self) delete_action.triggered.connect(self._delete_rows) delete_action.setIcon(get_icon("remove-24px.svg")) menu.addAction(delete_action) menu.exec_(QCursor.pos())
def __init__(self, parent, client, options): Panel.__init__(self, parent, client, options) loadUi(self, 'panels/scans.ui') ArbitraryFitter.arby_functions.update(options.get('fit_functions', {})) self.statusBar = QStatusBar(self, sizeGripEnabled=False) policy = self.statusBar.sizePolicy() policy.setVerticalPolicy(QSizePolicy.Fixed) self.statusBar.setSizePolicy(policy) self.layout().addWidget(self.statusBar) self.x_menu = QMenu(self) self.x_menu.aboutToShow.connect(self.on_x_menu_aboutToShow) self.actionXAxis.setMenu(self.x_menu) self.y_menu = QMenu(self) self.y_menu.aboutToShow.connect(self.on_y_menu_aboutToShow) self.actionYAxis.setMenu(self.y_menu) self.actionAutoDisplay.setChecked(True) self.norm_menu = QMenu(self) self.norm_menu.aboutToShow.connect(self.on_norm_menu_aboutToShow) self.actionNormalized.setMenu(self.norm_menu) quickfit = QShortcut(QKeySequence("G"), self) quickfit.activated.connect(self.on_quickfit) self.user_color = Qt.white self.user_font = QFont('Monospace') self.bulk_adding = False self.no_openset = False self.last_norm_selection = None self.fitclass = GaussFitter self.fitfuncmap = {} self.menus = None self.bars = None self.data = self.mainwindow.data # maps set uid -> plot self.setplots = {} # maps set uid -> list item self.setitems = {} # current plot object self.currentPlot = None # stack of set uids self.setUidStack = [] # uids of automatically combined datasets -> uid of combined one self.contSetUids = {} self.splitter.setSizes([20, 80]) self.splitter.restoreState(self.splitterstate) if self.tablecolwidth0 > 0: self.metaTable.setColumnWidth(0, self.tablecolwidth0) self.metaTable.setColumnWidth(1, self.tablecolwidth1) self.data.datasetAdded.connect(self.on_data_datasetAdded) self.data.pointsAdded.connect(self.on_data_pointsAdded) self.data.fitAdded.connect(self.on_data_fitAdded) client.experiment.connect(self.on_client_experiment) self.setCurrentDataset(None) self.updateList()
def on_tree_customContextMenuRequested(self, point): item = self.tree.itemAt(point) if item is None: return if item.type() == DEVICE_TYPE: self._menu_dev = item.text(0) ldevname = self._menu_dev.lower() if charmpowersupply in self._devinfo[ldevname].classes: params = self.client.getDeviceParams(ldevname) self.cpsmenu = QMenu() self.cps_actions = [] i = 0 for menuItem in params['transitions']: self.cps_actions.append(QAction(menuItem)) self.cpsmenu.addAction(self.cps_actions[i]) self.cps_actions[i].triggered.connect( partial(self.on_actionApply_triggered, i)) i = i + 1 self.cpsmenu.addSeparator() self.cpsmenu.addAction(self.actionMove) self.cpsmenu.addAction(self.actionReset) self.cpsmenu.addSeparator() if self.mainwindow.history_wintype is not None: self.cpsmenu.addAction(self.actionPlotHistory) self.cpsmenu.addSeparator() self.cpsmenu.addAction(self.actionShutDown) self.cpsmenu.addAction(self.actionHelp) self.cpsmenu.popup(self.tree.viewport().mapToGlobal(point)) return if roimanager in self._devinfo[ldevname].classes: params = self.client.getDeviceParams(ldevname) self.cpsmenu = QMenu() self.cps_actions = [] self.cps_actions.append(QAction('Edit...')) self.cpsmenu.addAction(self.cps_actions[0]) self.cps_actions[0].triggered.connect( partial(self.on_roimanagerEdit, ldevname)) self.cpsmenu.addSeparator() self.cpsmenu.addAction(self.actionMove) self.cpsmenu.addAction(self.actionReset) self.cpsmenu.addSeparator() if self.mainwindow.history_wintype is not None: self.cpsmenu.addAction(self.actionPlotHistory) self.cpsmenu.addSeparator() self.cpsmenu.addAction(self.actionShutDown) self.cpsmenu.addAction(self.actionHelp) self.cpsmenu.popup(self.tree.viewport().mapToGlobal(point)) return if compareimage in self._devinfo[ldevname].classes: params = self.client.getDeviceParams(ldevname) self.cpsmenu = QMenu() self.cps_actions = [] self.cps_actions.append(QAction('Show &Compare...')) self.cpsmenu.addAction(self.cps_actions[0]) self.cps_actions[0].triggered.connect( partial(self.on_images_compare, ldevname)) self.cpsmenu.addSeparator() self.cpsmenu.addAction(self.actionMove) self.cpsmenu.addAction(self.actionReset) self.cpsmenu.addSeparator() if self.mainwindow.history_wintype is not None: self.cpsmenu.addAction(self.actionPlotHistory) self.cpsmenu.addSeparator() self.cpsmenu.addAction(self.actionShutDown) self.cpsmenu.addAction(self.actionHelp) self.cpsmenu.popup(self.tree.viewport().mapToGlobal(point)) return if playlistmanager in self._devinfo[ldevname].classes: params = self.client.getDeviceParams(ldevname) self.cpsmenu = QMenu() self.cps_actions = [] self.cps_actions.append(QAction('Edit...')) self.cpsmenu.addAction(self.cps_actions[0]) self.cps_actions[0].triggered.connect( partial(self.on_playlist_edit, ldevname)) self.cpsmenu.addSeparator() self.cpsmenu.addAction(self.actionMove) self.cpsmenu.addAction(self.actionReset) self.cpsmenu.addSeparator() if self.mainwindow.history_wintype is not None: self.cpsmenu.addAction(self.actionPlotHistory) self.cpsmenu.addSeparator() self.cpsmenu.addAction(self.actionShutDown) self.cpsmenu.addAction(self.actionHelp) self.cpsmenu.popup(self.tree.viewport().mapToGlobal(point)) return return super().on_tree_customContextMenuRequested(point)
def __init__(self): loadUi(self, 'panels/history.ui') self.user_color = Qt.white self.user_font = QFont('Monospace') self.views = [] # stack of views to display self.viewStack = [] # maps watched keys to their views self.keyviews = {} # current plot object self.currentPlot = None self.fitclass = LinearFitter self.fitfuncmap = {} self.enablePlotActions(False) self.presetmenu = QMenu('&Presets', self) for (name, view) in self.last_views: item = QListWidgetItem(name, self.viewList) item.setForeground(QBrush(QColor('#aaaaaa'))) item.setData(Qt.UserRole, view) self.menus = None self.bar = None # NOTE: for this class, automatic connections don't work on PyQt4 >= # 4.12 since this class is not derived from QObject. But on older PyQt4 # and PyQt5, they do work, so we change use the usual naming scheme # slightly to avoid double connections. self.viewList.currentItemChanged.connect( self.on__viewList_currentItemChanged) self.viewList.itemClicked.connect(self.on__viewList_itemClicked) self.viewList.itemDoubleClicked.connect( self.on__viewList_itemDoubleClicked) self.actionNew.triggered.connect(self.on__actionNew_triggered) self.actionEditView.triggered.connect( self.on__actionEditView_triggered) self.actionCloseView.triggered.connect( self.on__actionCloseView_triggered) self.actionResetView.triggered.connect( self.on__actionResetView_triggered) self.actionDeleteView.triggered.connect( self.on__actionDeleteView_triggered) self.actionSavePlot.triggered.connect( self.on__actionSavePlot_triggered) self.actionPrint.triggered.connect(self.on__actionPrint_triggered) self.actionUnzoom.triggered.connect(self.on__actionUnzoom_triggered) self.actionLogScale.toggled.connect(self.on__actionLogScale_toggled) self.actionAutoScale.toggled.connect(self.on__actionAutoScale_toggled) self.actionScaleX.toggled.connect(self.on__actionScaleX_toggled) self.actionScaleY.toggled.connect(self.on__actionScaleY_toggled) self.actionLegend.toggled.connect(self.on__actionLegend_toggled) self.actionSymbols.toggled.connect(self.on__actionSymbols_toggled) self.actionLines.toggled.connect(self.on__actionLines_toggled) self.actionSaveData.triggered.connect( self.on__actionSaveData_triggered) self.actionFitPeak.triggered.connect(self.on__actionFitPeak_triggered) self.actionFitArby.triggered.connect(self.on__actionFitArby_triggered) self.actionFitPeakGaussian.triggered.connect( self.on__actionFitPeakGaussian_triggered) self.actionFitPeakLorentzian.triggered.connect( self.on__actionFitPeakLorentzian_triggered) self.actionFitPeakPV.triggered.connect( self.on__actionFitPeakPV_triggered) self.actionFitPeakPVII.triggered.connect( self.on__actionFitPeakPVII_triggered) self.actionFitTc.triggered.connect(self.on__actionFitTc_triggered) self.actionFitCosine.triggered.connect( self.on__actionFitCosine_triggered) self.actionFitSigmoid.triggered.connect( self.on__actionFitSigmoid_triggered) self.actionFitLinear.triggered.connect( self.on__actionFitLinear_triggered) self.actionFitExponential.triggered.connect( self.on__actionFitExponential_triggered)