Пример #1
0
    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)
Пример #2
0
    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())
Пример #3
0
    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)
Пример #4
0
 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)