コード例 #1
0
ファイル: shell.py プロジェクト: zhj149/spyder
 def setup_context_menu(self):
     """Reimplements ShellBaseWidget method"""
     ShellBaseWidget.setup_context_menu(self)
     self.copy_without_prompts_action = create_action(
         self,
         _("Copy without prompts"),
         icon=ima.icon('copywop'),
         triggered=self.copy_without_prompts)
     clear_line_action = create_action(
         self,
         _("Clear line"),
         QKeySequence(get_shortcut('console', 'Clear line')),
         icon=ima.icon('editdelete'),
         tip=_("Clear line"),
         triggered=self.clear_line)
     clear_action = create_action(self,
                                  _("Clear shell"),
                                  QKeySequence(
                                      get_shortcut('console',
                                                   'Clear shell')),
                                  icon=ima.icon('editclear'),
                                  tip=_("Clear shell contents "
                                        "('cls' command)"),
                                  triggered=self.clear_terminal)
     add_actions(self.menu, (self.copy_without_prompts_action,
                             clear_line_action, clear_action))
コード例 #2
0
 def add_actions_to_context_menu(self, menu):
     """Add actions to IPython widget context menu"""
     inspect_action = create_action(
         self,
         _("Inspect current object"),
         QKeySequence(get_shortcut('console', 'inspect current object')),
         icon=ima.icon('MessageBoxInformation'),
         triggered=self.inspect_object)
     clear_line_action = create_action(self,
                                       _("Clear line or block"),
                                       QKeySequence("Shift+Escape"),
                                       icon=ima.icon('editdelete'),
                                       triggered=self.clear_line)
     reset_namespace_action = create_action(self,
                                            _("Reset namespace"),
                                            QKeySequence("Ctrl+Alt+R"),
                                            triggered=self.reset_namespace)
     clear_console_action = create_action(
         self,
         _("Clear console"),
         QKeySequence(get_shortcut('console', 'clear shell')),
         icon=ima.icon('editclear'),
         triggered=self.clear_console)
     quit_action = create_action(self,
                                 _("&Quit"),
                                 icon=ima.icon('exit'),
                                 triggered=self.exit_callback)
     add_actions(
         menu,
         (None, inspect_action, clear_line_action, clear_console_action,
          reset_namespace_action, None, quit_action))
     return menu
コード例 #3
0
ファイル: client.py プロジェクト: jitseniesen/spyder
 def add_actions_to_context_menu(self, menu):
     """Add actions to IPython widget context menu"""
     inspect_action = create_action(self, _("Inspect current object"),
                                 QKeySequence(get_shortcut('console',
                                                 'inspect current object')),
                                 icon=ima.icon('MessageBoxInformation'),
                                 triggered=self.inspect_object)
     clear_line_action = create_action(self, _("Clear line or block"),
                                       QKeySequence("Shift+Escape"),
                                       icon=ima.icon('editdelete'),
                                       triggered=self.clear_line)
     reset_namespace_action = create_action(self, _("Reset namespace"),
                                       QKeySequence("Ctrl+Alt+R"),
                                       triggered=self.reset_namespace)
     clear_console_action = create_action(self, _("Clear console"),
                                          QKeySequence(get_shortcut('console',
                                                            'clear shell')),
                                          icon=ima.icon('editclear'),
                                          triggered=self.clear_console)
     quit_action = create_action(self, _("&Quit"), icon=ima.icon('exit'),
                                 triggered=self.exit_callback)
     add_actions(menu, (None, inspect_action, clear_line_action,
                        clear_console_action, reset_namespace_action,
                        None, quit_action))
     return menu
コード例 #4
0
 def context_menu_requested(self, event):
     """Popup context menu."""
     if self.fig:
         pos = QPoint(event.x(), event.y())
         context_menu = QMenu(self)
         context_menu.addAction(ima.icon('editcopy'), "Copy Image",
                                self.copy_figure,
                                QKeySequence(get_shortcut('plots', 'copy')))
         context_menu.popup(self.mapToGlobal(pos))
コード例 #5
0
        def setup_context_menu(self):
            """Setup context menu"""
            self.undo_action = create_action(self,
                                             _("Undo"),
                                             icon=ima.icon('undo'),
                                             shortcut=get_shortcut(
                                                 'editor', 'undo'),
                                             triggered=self.undo)
            self.redo_action = create_action(self,
                                             _("Redo"),
                                             icon=ima.icon('redo'),
                                             shortcut=get_shortcut(
                                                 'editor', 'redo'),
                                             triggered=self.redo)
            self.cut_action = create_action(self,
                                            _("Cut"),
                                            icon=ima.icon('editcut'),
                                            shortcut=get_shortcut(
                                                'editor', 'cut'),
                                            triggered=self.cut)
            self.copy_action = create_action(self,
                                             _("Copy"),
                                             icon=ima.icon('editcopy'),
                                             shortcut=get_shortcut(
                                                 'editor', 'copy'),
                                             triggered=self.copy)
            self.paste_action = create_action(self,
                                              _("Paste"),
                                              icon=ima.icon('editpaste'),
                                              shortcut=get_shortcut(
                                                  'editor', 'paste'),
                                              triggered=self.paste)
            selectall_action = create_action(self,
                                             _("Select All"),
                                             icon=ima.icon('selectall'),
                                             shortcut=get_shortcut(
                                                 'editor', 'select all'),
                                             triggered=self.selectAll)
            toggle_comment_action = create_action(
                self,
                _("Comment") + "/" + _("Uncomment"),
                icon=ima.icon('comment'),
                shortcut=get_shortcut('editor', 'toggle comment'),
                triggered=self.toggle_comment)

            # Build menu
            self.menu = QMenu(self)
            actions_1 = [
                self.undo_action, self.redo_action, None, self.cut_action,
                self.copy_action, self.paste_action, selectall_action
            ]
            actions_2 = [None, toggle_comment_action]
            actions = actions_1 + actions_2
            add_actions(self.menu, actions)

            # Read-only context-menu
            self.readonly_menu = QMenu(self)
            add_actions(self.readonly_menu,
                        (self.copy_action, selectall_action))
コード例 #6
0
ファイル: figurebrowser.py プロジェクト: impact27/spyder
 def context_menu_requested(self, event):
     """Popup context menu."""
     if self.fig:
         pos = QPoint(event.x(), event.y())
         context_menu = QMenu(self)
         context_menu.addAction(ima.icon('editcopy'), "Copy Image",
                                self.copy_figure,
                                QKeySequence(
                                    get_shortcut('plots', 'copy')))
         context_menu.popup(self.mapToGlobal(pos))
コード例 #7
0
ファイル: shell.py プロジェクト: ShenggaoZhu/spyder
 def setup_context_menu(self):
     """Reimplements ShellBaseWidget method"""
     ShellBaseWidget.setup_context_menu(self)
     self.copy_without_prompts_action = create_action(self,
                                  _("Copy without prompts"),
                                  icon=ima.icon('copywop'),
                                  triggered=self.copy_without_prompts)
     clear_line_action = create_action(self, _("Clear line"),
                                  QKeySequence(get_shortcut('console',
                                                            'Clear line')),
                                  icon=ima.icon('editdelete'),
                                  tip=_("Clear line"),
                                  triggered=self.clear_line)
     clear_action = create_action(self, _("Clear shell"),
                                  QKeySequence(get_shortcut('console',
                                                            'Clear shell')),
                                  icon=ima.icon('editclear'),
                                  tip=_("Clear shell contents "
                                        "('cls' command)"),
                                  triggered=self.clear_terminal)
     add_actions(self.menu, (self.copy_without_prompts_action,
                 clear_line_action, clear_action))
コード例 #8
0
    def setup_toolbar(self):
        """Setup the toolbar"""
        savefig_btn = create_toolbutton(self,
                                        icon=ima.icon('filesave'),
                                        tip=_("Save Image As..."),
                                        triggered=self.save_figure)

        saveall_btn = create_toolbutton(self,
                                        icon=ima.icon('save_all'),
                                        tip=_("Save All Images..."),
                                        triggered=self.save_all_figures)

        copyfig_btn = create_toolbutton(
            self,
            icon=ima.icon('editcopy'),
            tip=_("Copy plot to clipboard as image (%s)" %
                  get_shortcut('plots', 'copy')),
            triggered=self.copy_figure)

        closefig_btn = create_toolbutton(self,
                                         icon=ima.icon('editclear'),
                                         tip=_("Remove image"),
                                         triggered=self.close_figure)

        closeall_btn = create_toolbutton(
            self,
            icon=ima.icon('filecloseall'),
            tip=_("Remove all images from the explorer"),
            triggered=self.close_all_figures)

        vsep1 = QFrame()
        vsep1.setFrameStyle(53)

        goback_btn = create_toolbutton(self,
                                       icon=ima.icon('ArrowBack'),
                                       tip=_("Previous Figure ({})".format(
                                           get_shortcut(
                                               'plots', 'previous figure'))),
                                       triggered=self.go_previous_thumbnail)

        gonext_btn = create_toolbutton(self,
                                       icon=ima.icon('ArrowForward'),
                                       tip=_("Next Figure ({})".format(
                                           get_shortcut(
                                               'plots', 'next figure'))),
                                       triggered=self.go_next_thumbnail)

        vsep2 = QFrame()
        vsep2.setFrameStyle(53)

        zoom_out_btn = create_toolbutton(
            self,
            icon=ima.icon('zoom_out'),
            tip=_("Zoom out (Ctrl + mouse-wheel-down)"),
            triggered=self.zoom_out)

        zoom_in_btn = create_toolbutton(
            self,
            icon=ima.icon('zoom_in'),
            tip=_("Zoom in (Ctrl + mouse-wheel-up)"),
            triggered=self.zoom_in)

        self.zoom_disp = QSpinBox()
        self.zoom_disp.setAlignment(Qt.AlignCenter)
        self.zoom_disp.setButtonSymbols(QSpinBox.NoButtons)
        self.zoom_disp.setReadOnly(True)
        self.zoom_disp.setSuffix(' %')
        self.zoom_disp.setRange(0, 9999)
        self.zoom_disp.setValue(100)
        self.figviewer.sig_zoom_changed.connect(self.zoom_disp.setValue)

        zoom_pan = QWidget()
        layout = QHBoxLayout(zoom_pan)
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(zoom_out_btn)
        layout.addWidget(zoom_in_btn)
        layout.addWidget(self.zoom_disp)

        return [
            savefig_btn, saveall_btn, copyfig_btn, closefig_btn, closeall_btn,
            vsep1, goback_btn, gonext_btn, vsep2, zoom_pan
        ]
コード例 #9
0
 def load(self):
     self.key = get_shortcut(self.context, self.name)
コード例 #10
0
ファイル: figurebrowser.py プロジェクト: impact27/spyder
    def setup_toolbar(self):
        """Setup the toolbar"""
        savefig_btn = create_toolbutton(
                self, icon=ima.icon('filesave'),
                tip=_("Save Image As..."),
                triggered=self.save_figure)

        saveall_btn = create_toolbutton(
                self, icon=ima.icon('save_all'),
                tip=_("Save All Images..."),
                triggered=self.save_all_figures)

        copyfig_btn = create_toolbutton(
            self, icon=ima.icon('editcopy'),
            tip=_("Copy plot to clipboard as image (%s)" %
                  get_shortcut('plots', 'copy')),
            triggered=self.copy_figure)

        closefig_btn = create_toolbutton(
                self, icon=ima.icon('editclear'),
                tip=_("Remove image"),
                triggered=self.close_figure)

        closeall_btn = create_toolbutton(
                self, icon=ima.icon('filecloseall'),
                tip=_("Remove all images from the explorer"),
                triggered=self.close_all_figures)

        vsep1 = QFrame()
        vsep1.setFrameStyle(53)

        goback_btn = create_toolbutton(
                self, icon=ima.icon('ArrowBack'),
                tip=_("Previous Figure ({})".format(
                      get_shortcut('plots', 'previous figure'))),
                triggered=self.go_previous_thumbnail)

        gonext_btn = create_toolbutton(
                self, icon=ima.icon('ArrowForward'),
                tip=_("Next Figure ({})".format(
                      get_shortcut('plots', 'next figure'))),
                triggered=self.go_next_thumbnail)

        vsep2 = QFrame()
        vsep2.setFrameStyle(53)

        zoom_out_btn = create_toolbutton(
                self, icon=ima.icon('zoom_out'),
                tip=_("Zoom out (Ctrl + mouse-wheel-down)"),
                triggered=self.zoom_out)

        zoom_in_btn = create_toolbutton(
                self, icon=ima.icon('zoom_in'),
                tip=_("Zoom in (Ctrl + mouse-wheel-up)"),
                triggered=self.zoom_in)

        self.zoom_disp = QSpinBox()
        self.zoom_disp.setAlignment(Qt.AlignCenter)
        self.zoom_disp.setButtonSymbols(QSpinBox.NoButtons)
        self.zoom_disp.setReadOnly(True)
        self.zoom_disp.setSuffix(' %')
        self.zoom_disp.setRange(0, 9999)
        self.zoom_disp.setValue(100)
        self.figviewer.sig_zoom_changed.connect(self.zoom_disp.setValue)

        zoom_pan = QWidget()
        layout = QHBoxLayout(zoom_pan)
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(zoom_out_btn)
        layout.addWidget(zoom_in_btn)
        layout.addWidget(self.zoom_disp)

        return [savefig_btn, saveall_btn, copyfig_btn, closefig_btn,
                closeall_btn, vsep1, goback_btn, gonext_btn, vsep2, zoom_pan]
コード例 #11
0
ファイル: qthelpers.py プロジェクト: Even8090/hrv_features
def add_shortcut_to_tooltip(action, context, name):
    """Add the shortcut associated with a given action to its tooltip"""
    action.setToolTip(action.toolTip() +
                      ' (%s)' % get_shortcut(context=context, name=name))
コード例 #12
0
ファイル: test_shortcuts.py プロジェクト: zalois/spyder
def test_default_keybinding_values():
    """
    Assert that the default Spyder keybindings for the keyboard shorcuts
    are as expected. This is required because we do not use the keybindings
    saved in Spyder's config to simulate the user keyboard action, due to
    the fact that it is complicated to convert and pass reliably a sequence
    of key strings to qtbot.keyClicks.
    """
    # Assert default keybindings.
    assert get_shortcut('editor', 'start of document') == 'Ctrl+Home'
    assert get_shortcut('editor', 'end of document') == 'Ctrl+End'
    assert get_shortcut('editor', 'delete') == 'Del'
    assert get_shortcut('editor', 'undo') == 'Ctrl+Z'
    assert get_shortcut('editor', 'redo') == 'Ctrl+Shift+Z'
    assert get_shortcut('editor', 'copy') == 'Ctrl+C'
    assert get_shortcut('editor', 'paste') == 'Ctrl+V'
    assert get_shortcut('editor', 'cut') == 'Ctrl+X'
    assert get_shortcut('editor', 'select all') == 'Ctrl+A'
    assert get_shortcut('editor', 'delete line') == 'Ctrl+D'
    assert get_shortcut('editor', 'transform to lowercase') == 'Ctrl+U'
    assert get_shortcut('editor', 'transform to uppercase') == 'Ctrl+Shift+U'
    assert get_shortcut('editor', 'go to line') == 'Ctrl+L'
    assert get_shortcut('editor', 'next word') == 'Ctrl+Right'
    assert get_shortcut('editor', 'previous word') == 'Ctrl+Left'
コード例 #13
0
ファイル: shortcuts.py プロジェクト: 0xBADCA7/spyder
 def load(self):
     self.key = get_shortcut(self.context, self.name)
コード例 #14
0
ファイル: test_shortcuts.py プロジェクト: burrbull/spyder
def test_default_keybinding_values():
    """
    Assert that the default Spyder keybindings for the keyboard shorcuts
    are as expected. This is required because we do not use the keybindings
    saved in Spyder's config to simulate the user keyboard action, due to
    the fact that it is complicated to convert and pass reliably a sequence
    of key strings to qtbot.keyClicks.
    """
    # Assert default keybindings.
    assert get_shortcut('editor', 'start of document') == 'Ctrl+Home'
    assert get_shortcut('editor', 'end of document') == 'Ctrl+End'
    assert get_shortcut('editor', 'delete') == 'Del'
    assert get_shortcut('editor', 'undo') == 'Ctrl+Z'
    assert get_shortcut('editor', 'redo') == 'Ctrl+Shift+Z'
    assert get_shortcut('editor', 'copy') == 'Ctrl+C'
    assert get_shortcut('editor', 'paste') == 'Ctrl+V'
    assert get_shortcut('editor', 'cut') == 'Ctrl+X'
    assert get_shortcut('editor', 'select all') == 'Ctrl+A'
    assert get_shortcut('editor', 'delete line') == 'Ctrl+D'
    assert get_shortcut('editor', 'transform to lowercase') == 'Ctrl+U'
    assert get_shortcut('editor', 'transform to uppercase') == 'Ctrl+Shift+U'
    assert get_shortcut('editor', 'go to line') == 'Ctrl+L'
    assert get_shortcut('editor', 'next word') == 'Ctrl+Right'
    assert get_shortcut('editor', 'previous word') == 'Ctrl+Left'
コード例 #15
0
ファイル: qthelpers.py プロジェクト: silentquasar/spyder
def add_shortcut_to_tooltip(action, context, name):
    """Add the shortcut associated with a given action to its tooltip"""
    action.setToolTip(action.toolTip() + ' (%s)' %
                      get_shortcut(context=context, name=name))