示例#1
0
文件: shell.py 项目: mikofski/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 contextMenuEvent(self, event):
        index_clicked = self.indexAt(event.pos())
        actions = []
        self.popup_menu = QMenu(self)
        clear_all_breakpoints_action = create_action(
            self,
            _("Clear breakpoints in all files"),
            triggered=lambda: self.clear_all_breakpoints.emit())
        actions.append(clear_all_breakpoints_action)
        if self.model.breakpoints:
            filename = self.model.breakpoints[index_clicked.row()][0]
            lineno = int(self.model.breakpoints[index_clicked.row()][1])
            clear_breakpoint_action = create_action(self,
                    _("Clear this breakpoint"),
                    triggered=lambda filename=filename, lineno=lineno: \
                    self.clear_breakpoint.emit(filename, lineno))
            actions.insert(0, clear_breakpoint_action)

            edit_breakpoint_action = create_action(self,
                    _("Edit this breakpoint"),
                    triggered=lambda filename=filename, lineno=lineno: \
                    (self.edit_goto.emit(filename, lineno, ''),
                     self.set_or_edit_conditional_breakpoint.emit())
                    )
            actions.append(edit_breakpoint_action)
        add_actions(self.popup_menu, actions)
        self.popup_menu.popup(event.globalPos())
        event.accept()
示例#3
0
    def __init__(self, parent):
        PluginWidget.__init__(self, parent)

        # Read-only editor
        self.editor = QsciEditor(self)
        self.editor.setup_editor(linenumbers=False, language='py',
                                 code_folding=True)
        self.connect(self.editor, SIGNAL("focus_changed()"),
                     lambda: self.emit(SIGNAL("focus_changed()")))
        self.editor.setReadOnly(True)
        self.editor.set_font( get_font(self.ID) )
        self.editor.toggle_wrap_mode( CONF.get(self.ID, 'wrap') )
        
        # Add entries to read-only editor context-menu
        font_action = create_action(self, translate("Editor", "&Font..."), None,
                                    'font.png',
                                    translate("Editor", "Set font style"),
                                    triggered=self.change_font)
        wrap_action = create_action(self, translate("Editor", "Wrap lines"),
                                    toggled=self.toggle_wrap_mode)
        wrap_action.setChecked( CONF.get(self.ID, 'wrap') )
        self.editor.readonly_menu.addSeparator()
        add_actions(self.editor.readonly_menu, (font_action, wrap_action))
        
        # Find/replace widget
        self.find_widget = FindReplace(self)
        self.find_widget.set_editor(self.editor)
        self.find_widget.hide()
示例#4
0
 def setup_context_menu(self):
     """Setup shell context menu"""
     self.menu = QMenu(self)
     self.cut_action = create_action(self,
                                     translate("ShellBaseWidget", "Cut"),
                                     shortcut=keybinding('Cut'),
                                     icon=get_icon('editcut.png'),
                                     triggered=self.cut)
     self.copy_action = create_action(self,
                                      translate("ShellBaseWidget", "Copy"),
                                      shortcut=keybinding('Copy'),
                                      icon=get_icon('editcopy.png'),
                                      triggered=self.copy)
     paste_action = create_action(self,
                                  translate("ShellBaseWidget", "Paste"),
                                  shortcut=keybinding('Paste'),
                                  icon=get_icon('editpaste.png'),
                                  triggered=self.paste)
     save_action = create_action(self,
                                 translate("ShellBaseWidget",
                                           "Save history log..."),
                                 icon=get_icon('filesave.png'),
                                 tip=translate(
                                     "ShellBaseWidget",
                                     "Save current history log (i.e. all "
                                     "inputs and outputs) in a text file"),
                                 triggered=self.save_historylog)
     add_actions(self.menu, (self.cut_action, self.copy_action,
                             paste_action, None, save_action))
示例#5
0
 def setup_common_actions(self):
     """Setup context menu common actions"""
     self.collapse_all_action = create_action(self,
                      text=translate('OneColumnTree', 'Collapse all'),
                      icon=get_icon('collapse.png'),
                      triggered=self.collapseAll)
     self.expand_all_action = create_action(self,
                      text=translate('OneColumnTree', 'Expand all'),
                      icon=get_icon('expand.png'),
                      triggered=self.expandAll)
     self.restore_action = create_action(self,
                      text=translate('OneColumnTree', 'Restore'),
                      tip=translate('OneColumnTree',
                                    'Restore original tree layout'),
                      icon=get_icon('restore.png'),
                      triggered=self.restore)
     self.collapse_selection_action = create_action(self,
                      text=translate('OneColumnTree', 'Collapse selection'),
                      icon=get_icon('collapse_selection.png'),
                      triggered=self.collapse_selection)
     self.expand_selection_action = create_action(self,
                      text=translate('OneColumnTree', 'Expand selection'),
                      icon=get_icon('expand_selection.png'),
                      triggered=self.expand_selection)
     return [self.collapse_all_action, self.expand_all_action,
             self.restore_action, None,
             self.collapse_selection_action, self.expand_selection_action]
示例#6
0
 def get_plugin_actions(self):
     """Return a list of actions related to plugin"""
     quit_action = create_action(self, _("&Quit"),
                                 icon=ima.icon('exit'), 
                                 tip=_("Quit"),
                                 triggered=self.quit)
     self.register_shortcut(quit_action, "_", "Quit", "Ctrl+Q")
     run_action = create_action(self, _("&Run..."), None,
                         ima.icon('run_small'),
                         _("Run a Python script"),
                         triggered=self.run_script)
     environ_action = create_action(self,
                         _("Environment variables..."),
                         icon=ima.icon('environ'),
                         tip=_("Show and edit environment variables"
                                     " (for current session)"),
                         triggered=self.show_env)
     syspath_action = create_action(self,
                         _("Show sys.path contents..."),
                         icon=ima.icon('syspath'),
                         tip=_("Show (read-only) sys.path"),
                         triggered=self.show_syspath)
     buffer_action = create_action(self,
                         _("Buffer..."), None,
                         tip=_("Set maximum line count"),
                         triggered=self.change_max_line_count)
     exteditor_action = create_action(self,
                         _("External editor path..."), None, None,
                         _("Set external editor executable path"),
                         triggered=self.change_exteditor)
     wrap_action = create_action(self,
                         _("Wrap lines"),
                         toggled=self.toggle_wrap_mode)
     wrap_action.setChecked(self.get_option('wrap'))
     calltips_action = create_action(self, _("Display balloon tips"),
         toggled=self.toggle_calltips)
     calltips_action.setChecked(self.get_option('calltips'))
     codecompletion_action = create_action(self,
                                       _("Automatic code completion"),
                                       toggled=self.toggle_codecompletion)
     codecompletion_action.setChecked(self.get_option('codecompletion/auto'))
     codecompenter_action = create_action(self,
                                 _("Enter key selects completion"),
                                 toggled=self.toggle_codecompletion_enter)
     codecompenter_action.setChecked(self.get_option(
                                                 'codecompletion/enter_key'))
     
     option_menu = QMenu(_('Internal console settings'), self)
     option_menu.setIcon(ima.icon('tooloptions'))
     add_actions(option_menu, (buffer_action, wrap_action,
                               calltips_action, codecompletion_action,
                               codecompenter_action, exteditor_action))
                 
     plugin_actions = [None, run_action, environ_action, syspath_action,
                       option_menu, None, quit_action]
     
     # Add actions to context menu
     add_actions(self.shell.menu, plugin_actions)
     
     return plugin_actions
示例#7
0
 def setup_common_actions(self):
     """Setup context menu common actions"""
     self.collapse_all_action = create_action(self,
                                  text=_('Collapse all'),
                                  icon=ima.icon('collapse'),
                                  triggered=self.collapseAll)
     self.expand_all_action = create_action(self,
                                  text=_('Expand all'),
                                  icon=ima.icon('expand'),
                                  triggered=self.expandAll)
     self.restore_action = create_action(self,
                                  text=_('Restore'),
                                  tip=_('Restore original tree layout'),
                                  icon=ima.icon('restore'),
                                  triggered=self.restore)
     self.collapse_selection_action = create_action(self,
                                  text=_('Collapse selection'),
                                  icon=ima.icon('collapse_selection'),
                                  triggered=self.collapse_selection)
     self.expand_selection_action = create_action(self,
                                  text=_('Expand selection'),
                                  icon=ima.icon('expand_selection'),
                                  triggered=self.expand_selection)
     return [self.collapse_all_action, self.expand_all_action,
             self.restore_action, None,
             self.collapse_selection_action, self.expand_selection_action]
示例#8
0
 def add_actions_to_context_menu(self, menu):
     """Add actions to IPython widget context menu"""
     # See spyderlib/widgets/ipython.py for more details on this method
     inspect_action = create_action(
         self,
         _("Inspect current object"),
         QKeySequence(get_shortcut('console', 'inspect current object')),
         icon=get_std_icon('MessageBoxInformation'),
         triggered=self.inspect_object)
     clear_line_action = create_action(self,
                                       _("Clear line or block"),
                                       QKeySequence("Shift+Escape"),
                                       icon=get_icon('eraser.png'),
                                       triggered=self.clear_line)
     clear_console_action = create_action(
         self,
         _("Clear console"),
         QKeySequence(get_shortcut('console', 'clear shell')),
         icon=get_icon('clear.png'),
         triggered=self.clear_console)
     quit_action = create_action(self,
                                 _("&Quit"),
                                 icon='exit.png',
                                 triggered=self.exit_callback)
     add_actions(menu, (None, inspect_action, clear_line_action,
                        clear_console_action, None, quit_action))
     return menu
示例#9
0
    def get_plugin_actions(self):
        """Return a list of actions related to plugin"""
        create_client_action = create_action(self,
                                             _("Open an &IPython console"),
                                             None,
                                             'ipython_console.png',
                                             triggered=self.create_new_client)

        connect_to_kernel_action = create_action(
            self,
            _("Connect to an existing kernel"),
            None,
            None,
            _("Open a new IPython console connected to an existing kernel"),
            triggered=self.create_client_for_kernel)

        # Add the action to the 'Consoles' menu on the main window
        main_consoles_menu = self.main.consoles_menu_actions
        main_consoles_menu.insert(0, create_client_action)
        main_consoles_menu += [None, connect_to_kernel_action]

        # Plugin actions
        self.menu_actions = [create_client_action, connect_to_kernel_action]

        return self.menu_actions
示例#10
0
 def create_file_new_actions(self, fnames):
     """Return actions for submenu 'New...'"""
     if not fnames:
         return []
     new_file_act = create_action(
         self,
         _("File..."),
         icon=ima.icon('filenew'),
         triggered=lambda: self.new_file(fnames[-1]))
     new_module_act = create_action(
         self,
         _("Module..."),
         icon=ima.icon('spyder'),
         triggered=lambda: self.new_module(fnames[-1]))
     new_folder_act = create_action(
         self,
         _("Folder..."),
         icon=ima.icon('folder_new'),
         triggered=lambda: self.new_folder(fnames[-1]))
     new_package_act = create_action(
         self,
         _("Package..."),
         icon=ima.icon('package_new'),
         triggered=lambda: self.new_package(fnames[-1]))
     return [
         new_file_act, new_folder_act, None, new_module_act, new_package_act
     ]
示例#11
0
 def __init__(self, parent):
     QWebView.__init__(self, parent)
     self.zoom_factor = 1.0
     self.zoom_out_action = create_action(
         self, _("Zoom out"), icon=get_icon("zoom_out.png"), triggered=self.zoom_out
     )
     self.zoom_in_action = create_action(self, _("Zoom in"), icon=get_icon("zoom_in.png"), triggered=self.zoom_in)
示例#12
0
 def setup_context_menu(self):
     """Setup shell context menu"""
     self.menu = QMenu(self)
     self.cut_action = create_action(self,
                                     translate("ShellBaseWidget", "Cut"),
                                     shortcut=keybinding('Cut'),
                                     icon=get_icon('editcut.png'),
                                     triggered=self.cut)
     self.copy_action = create_action(self,
                                      translate("ShellBaseWidget", "Copy"),
                                      shortcut=keybinding('Copy'),
                                      icon=get_icon('editcopy.png'),
                                      triggered=self.copy)
     paste_action = create_action(self,
                                  translate("ShellBaseWidget", "Paste"),
                                  shortcut=keybinding('Paste'),
                                  icon=get_icon('editpaste.png'),
                                  triggered=self.paste)
     save_action = create_action(self,
                                 translate("ShellBaseWidget",
                                           "Save history log..."),
                                 icon=get_icon('filesave.png'),
                                 tip=translate("ShellBaseWidget",
                                       "Save current history log (i.e. all "
                                       "inputs and outputs) in a text file"),
                                 triggered=self.save_historylog)
     add_actions(self.menu, (self.cut_action, self.copy_action,
                             paste_action, None, save_action) )
示例#13
0
    def __init__(self, parent, data, readonly=False, title="",
                 names=False, truncate=True, minmax=False,
                 inplace=False, collvalue=True):
        BaseTableView.__init__(self, parent)
        self.dictfilter = None
        self.readonly = readonly or isinstance(data, tuple)
        self.model = None
        self.delegate = None
        DictModelClass = ReadOnlyDictModel if self.readonly else DictModel
        self.model = DictModelClass(self, data, title, names=names,
                                    truncate=truncate, minmax=minmax,
                                    collvalue=collvalue)
        self.setModel(self.model)
        self.delegate = DictDelegate(self, inplace=inplace)
        self.setItemDelegate(self.delegate)

        self.setup_table()
        self.menu = self.setup_menu(truncate, minmax, inplace, collvalue)
        self.copy_action = create_action(self,
                                      translate("DictEditor", "Copy"),
                                      icon=get_icon('editcopy.png'),
                                      triggered=self.copy)                                      
        self.paste_action = create_action(self,
                                      translate("DictEditor", "Paste"),
                                      icon=get_icon('editpaste.png'),
                                      triggered=self.paste)
        self.menu.insertAction(self.remove_action, self.copy_action)
        self.menu.insertAction(self.remove_action, self.paste_action)
        
        self.empty_ws_menu = QMenu(self)
        self.empty_ws_menu.addAction(self.paste_action)
示例#14
0
    def contextMenuEvent(self, event):
        index_clicked = self.indexAt(event.pos())
        actions = []
        self.popup_menu = QMenu(self)
        clear_all_breakpoints_action = create_action(
            self, _("Clear breakpoints in all files"), triggered=lambda: self.clear_all_breakpoints.emit()
        )
        actions.append(clear_all_breakpoints_action)
        if self.model.breakpoints:
            filename = self.model.breakpoints[index_clicked.row()][0]
            lineno = int(self.model.breakpoints[index_clicked.row()][1])
            clear_breakpoint_action = create_action(
                self,
                _("Clear this breakpoint"),
                triggered=lambda filename=filename, lineno=lineno: self.clear_breakpoint.emit(filename, lineno),
            )
            actions.insert(0, clear_breakpoint_action)

            edit_breakpoint_action = create_action(
                self,
                _("Edit this breakpoint"),
                triggered=lambda filename=filename, lineno=lineno: (
                    self.edit_goto.emit(filename, lineno, ""),
                    self.set_or_edit_conditional_breakpoint.emit(),
                ),
            )
            actions.append(edit_breakpoint_action)
        add_actions(self.popup_menu, actions)
        self.popup_menu.popup(event.globalPos())
        event.accept()
示例#15
0
文件: ipython.py 项目: G-VAR/spyder
 def add_actions_to_context_menu(self, menu):
     """Add actions to IPython widget context menu"""
     # See spyderlib/widgets/ipython.py for more details on this method
     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+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
示例#16
0
 def setup_context_menu(self):
     """Reimplements ShellBaseWidget method"""
     ShellBaseWidget.setup_context_menu(self)
     self.copy_without_prompts_action = create_action(self,
                                  translate("PythonShellWidget",
                                            "Copy without prompts"),
                                  icon=get_icon('copywop.png'),
                                  triggered=self.copy_without_prompts)
     clear_line_action = create_action(self, translate("PythonShellWidget",
                                                       "Clear line"),
                                  QKeySequence("Escape"),
                                  icon=get_icon('eraser.png'),
                                  tip=translate("PythonShellWidget",
                                                "Clear line"),
                                  triggered=self.clear_line)
     clear_action = create_action(self,
                                  translate("PythonShellWidget",
                                            "Clear shell"),
                                  icon=get_icon('clear.png'),
                                  tip=translate("PythonShellWidget",
                                                "Clear shell contents "
                                              "('cls' command)"),
                                  triggered=self.clear_terminal)
     add_actions(self.menu, (self.copy_without_prompts_action,
                 clear_line_action, clear_action))
示例#17
0
 def create_file_new_actions(self, fnames):
     """Return actions for submenu 'New...'"""
     if not fnames:
         return []
     new_file_act = create_action(
         self,
         _("File..."),
         icon=ima.icon('filenew'),
         triggered=lambda: self.new_file(fnames[-1]))
     new_module_act = create_action(
         self,
         _("Module..."),
         icon=ima.icon('spyder'),
         triggered=lambda: self.new_module(fnames[-1]))
     new_folder_act = create_action(
         self,
         _("Folder..."),
         icon=ima.icon('folder_new'),
         triggered=lambda: self.new_folder(fnames[-1]))
     new_package_act = create_action(
         self,
         _("Package..."),
         icon=ima.icon('package_new'),
         triggered=lambda: self.new_package(fnames[-1]))
     return [
         new_file_act, new_folder_act, None, new_module_act, new_package_act
     ]
示例#18
0
 def setup_menu(self):
     """Setup context menu"""
     copy_action = create_action(
         self,
         _("Copy"),
         shortcut=keybinding("Copy"),
         icon=get_icon("editcopy.png"),
         triggered=self.copy,
         context=Qt.WidgetShortcut,
     )
     functions = (
         (_("To bool"), bool),
         (_("To complex"), complex),
         (_("To int"), int),
         (_("To float"), float),
         (_("To str"), to_text_string),
     )
     types_in_menu = [copy_action]
     for name, func in functions:
         types_in_menu += [
             create_action(self, name, triggered=lambda func=func: self.change_type(func), context=Qt.WidgetShortcut)
         ]
     menu = QMenu(self)
     add_actions(menu, types_in_menu)
     return menu
示例#19
0
 def setup_menu(self):
     """Setup context menu"""
     copy_action = create_action(self,
                                 _('Copy'),
                                 shortcut=keybinding('Copy'),
                                 icon=ima.icon('editcopy'),
                                 triggered=self.copy,
                                 context=Qt.WidgetShortcut)
     functions = ((_("To bool"), bool), (_("To complex"),
                                         complex), (_("To int"), int),
                  (_("To float"), float), (_("To str"), to_text_string))
     types_in_menu = [copy_action]
     for name, func in functions:
         # QAction.triggered works differently for PySide and PyQt
         if not API == 'pyside':
             slot = lambda _checked, func=func: self.change_type(func)
         else:
             slot = lambda func=func: self.change_type(func)
         types_in_menu += [
             create_action(self,
                           name,
                           triggered=slot,
                           context=Qt.WidgetShortcut)
         ]
     menu = QMenu(self)
     add_actions(menu, types_in_menu)
     return menu
示例#20
0
 def get_options_menu(self):
     self.interact_action = create_action(self, self.tr("Interact"))
     self.interact_action.setCheckable(True)
     self.debug_action = create_action(self, self.tr("Debug"))
     self.debug_action.setCheckable(True)
     self.args_action = create_action(self, self.tr("Arguments..."),
                                      triggered=self.get_arguments)
     return [self.interact_action, self.debug_action, self.args_action]
示例#21
0
文件: browser.py 项目: CVML/spyder
 def __init__(self, parent):
     QWebView.__init__(self, parent)
     self.zoom_factor = 1.
     self.zoom_out_action = create_action(self, _("Zoom out"),
                                          icon=ima.icon('zoom_out'),
                                          triggered=self.zoom_out)
     self.zoom_in_action = create_action(self, _("Zoom in"),
                                         icon=ima.icon('zoom_in'),
                                         triggered=self.zoom_in)
示例#22
0
 def __init__(self, parent):
     QWebView.__init__(self, parent)
     self.zoom_factor = 1.
     self.zoom_out_action = create_action(self, _("Zoom out"),
                                          icon=ima.icon('zoom_out'),
                                          triggered=self.zoom_out)
     self.zoom_in_action = create_action(self, _("Zoom in"),
                                         icon=ima.icon('zoom_in'),
                                         triggered=self.zoom_in)
示例#23
0
 def get_plugin_actions(self):
     """Return a list of actions related to plugin"""
     history_action = create_action(self, _("History..."),
                                    None, ima.icon('history'),
                                    _("Set history maximum entries"),
                                    triggered=self.change_history_depth)
     self.wrap_action = create_action(self, _("Wrap lines"),
                                 toggled=self.toggle_wrap_mode)
     self.wrap_action.setChecked( self.get_option('wrap') )
     self.menu_actions = [history_action, self.wrap_action]
     return self.menu_actions
示例#24
0
    def __init__(self, parent=None, name_filters=['*.py', '*.pyw'],
                 show_all=False, show_cd_only=None, show_icontext=True):
        QWidget.__init__(self, parent)
        
        self.treewidget = ExplorerTreeWidget(self, show_cd_only=show_cd_only)
        self.treewidget.setup(name_filters=name_filters, show_all=show_all)
        self.treewidget.chdir(getcwd())
        
        icontext_action = create_action(self, _("Show icons and text"),
                                        toggled=self.toggle_icontext)
        self.treewidget.common_actions += [None, icontext_action]
        
        # Setup toolbar
        self.toolbar = QToolBar(self)
        self.toolbar.setIconSize(QSize(16, 16))
        
        self.previous_action = create_action(self, text=_("Previous"),
                            icon=get_std_icon("ArrowBack"),
                            triggered=self.treewidget.go_to_previous_directory)
        self.toolbar.addAction(self.previous_action)
        self.previous_action.setEnabled(False)
        self.connect(self.treewidget, SIGNAL("set_previous_enabled(bool)"),
                     self.previous_action.setEnabled)
        
        self.next_action = create_action(self, text=_("Next"),
                            icon=get_std_icon("ArrowForward"),
                            triggered=self.treewidget.go_to_next_directory)
        self.toolbar.addAction(self.next_action)
        self.next_action.setEnabled(False)
        self.connect(self.treewidget, SIGNAL("set_next_enabled(bool)"),
                     self.next_action.setEnabled)
        
        parent_action = create_action(self, text=_("Parent"),
                            icon=get_std_icon("ArrowUp"),
                            triggered=self.treewidget.go_to_parent_directory)
        self.toolbar.addAction(parent_action)
        self.toolbar.addSeparator()

        options_action = create_action(self, text='', tip=_("Options"),
                                       icon=get_icon('tooloptions.png'))
        self.toolbar.addAction(options_action)
        widget = self.toolbar.widgetForAction(options_action)
        widget.setPopupMode(QToolButton.InstantPopup)
        menu = QMenu(self)
        add_actions(menu, self.treewidget.common_actions)
        options_action.setMenu(menu)
            
        icontext_action.setChecked(show_icontext)
        self.toggle_icontext(show_icontext)     
        
        vlayout = QVBoxLayout()
        vlayout.addWidget(self.toolbar)
        vlayout.addWidget(self.treewidget)
        self.setLayout(vlayout)
示例#25
0
    def __init__(self, parent):
        ReadOnlyEditor.__init__(self, parent)
        
        self.shell = None
        
        self.external_console = None
        
        # locked = disable link with Console
        self.locked = False
        self._last_text = None
        
        # Object name
        layout_edit = QHBoxLayout()
        layout_edit.addWidget(QLabel(self.tr("Object")))
        self.combo = ObjectComboBox(self)
        layout_edit.addWidget(self.combo)
        self.combo.setMaxCount(CONF.get(self.ID, 'max_history_entries'))
        self.combo.addItems( self.load_history() )
        self.connect(self.combo, SIGNAL("valid(bool)"),
                     lambda valid: self.force_refresh())
        
        # Doc/source option
        help_or_doc = create_action(self, self.tr("Show source"),
                                    toggled=self.toggle_help)
        help_or_doc.setChecked(False)
        self.docstring = True
        
        # Automatic import option
        auto_import = create_action(self, self.tr("Automatic import"),
                                    toggled=self.toggle_auto_import)
        auto_import_state = CONF.get('inspector', 'automatic_import')
        auto_import.setChecked(auto_import_state)
        
        # Lock checkbox
        self.locked_button = create_toolbutton(self,
                                               triggered=self.toggle_locked)
        layout_edit.addWidget(self.locked_button)
        self._update_lock_icon()
        
        # Option menu
        options_button = create_toolbutton(self, text=self.tr("Options"),
                                           icon=get_icon('tooloptions.png'))
        options_button.setPopupMode(QToolButton.InstantPopup)
        menu = QMenu(self)
        add_actions(menu, [help_or_doc, auto_import])
        options_button.setMenu(menu)
        layout_edit.addWidget(options_button)

        # Main layout
        layout = QVBoxLayout()
        layout.addLayout(layout_edit)
        layout.addWidget(self.editor)
        layout.addWidget(self.find_widget)
        self.setLayout(layout)
示例#26
0
 def setup_common_actions(self):
     """Setup context menu common actions"""
     collapse_act = create_action(self,
                 text=self.tr('Collapse all'),
                 icon=get_icon('collapse.png'),
                 triggered=self.collapseAll)
     expand_act = create_action(self,
                 text=self.tr('Expand all'),
                 icon=get_icon('expand.png'),
                 triggered=self.expandAll)
     return [collapse_act, expand_act]
示例#27
0
 def __init__(self, parent):
     QWebEngineView.__init__(self, parent)
     self.zoom_factor = 1.
     self.zoom_out_action = create_action(self, _("Zoom out"),
                                          icon=ima.icon('zoom_out'),
                                          triggered=self.zoom_out)
     self.zoom_in_action = create_action(self, _("Zoom in"),
                                         icon=ima.icon('zoom_in'),
                                         triggered=self.zoom_in)
     if WEBENGINE:
         web_page = WebPage(self)
         self.setPage(web_page)
示例#28
0
    def get_plugin_actions(self):
        """Setup actions"""
        self.new_project_action = create_action(self,
                                        text=self.tr('New project...'),
                                        icon=get_icon('project_expanded.png'),
                                        triggered=self.create_new_project)

        font_action = create_action(self, self.tr("&Font..."),
                                    None, 'font.png', self.tr("Set font style"),
                                    triggered=self.change_font)
        self.treewidget.common_actions += (None, font_action)
        return (None, None)
示例#29
0
 def get_plugin_actions(self):
     """Setup actions"""
     # Font
     history_action = create_action(self, self.tr("History..."),
                                    None, 'history.png',
                                    self.tr("Set history maximum entries"),
                                    triggered=self.change_history_depth)
     font_action = create_action(self, self.tr("&Font..."),
                                 None, 'font.png', self.tr("Set font style"),
                                 triggered=self.change_font)
     self.treewidget.common_actions += (None, history_action, font_action)
     return (None, None)
示例#30
0
    def setup_common_actions(self):
        """Setup context menu common actions"""
        # Filters
        filters_action = create_action(
            self, _("Edit filename filters..."), None, ima.icon("filter"), triggered=self.edit_filter
        )
        # Show all files
        all_action = create_action(self, _("Show all files"), toggled=self.toggle_all)
        all_action.setChecked(self.show_all)
        self.toggle_all(self.show_all)

        return [filters_action, all_action]
示例#31
0
 def create_toggle_view_action(self):
     """Associate a toggle view action with each plugin"""
     title = self.get_plugin_title()
     if self.CONF_SECTION == 'editor':
         title = _('Editor')
     if self.shortcut is not None:
         action = create_action(self, title, toggled=self.toggle_view,
                                shortcut=QKeySequence(self.shortcut))
         action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
     else:
         action = create_action(self, title, toggled=self.toggle_view)
     self.toggle_view_action = action
示例#32
0
文件: browser.py 项目: DLlearn/spyder
 def __init__(self, parent):
     QWebEngineView.__init__(self, parent)
     self.zoom_factor = 1.
     self.zoom_out_action = create_action(self, _("Zoom out"),
                                          icon=ima.icon('zoom_out'),
                                          triggered=self.zoom_out)
     self.zoom_in_action = create_action(self, _("Zoom in"),
                                         icon=ima.icon('zoom_in'),
                                         triggered=self.zoom_in)
     if WEBENGINE:
         web_page = WebPage(self)
         self.setPage(web_page)
示例#33
0
 def get_actions_from_items(self, items):
     """Reimplemented OneColumnTree method"""
     fromcursor_act = create_action(
         self, text=_("Go to cursor position"), icon=ima.icon("fromcursor"), triggered=self.go_to_cursor_position
     )
     fullpath_act = create_action(self, text=_("Show absolute path"), toggled=self.toggle_fullpath_mode)
     fullpath_act.setChecked(self.show_fullpath)
     allfiles_act = create_action(self, text=_("Show all files"), toggled=self.toggle_show_all_files)
     allfiles_act.setChecked(self.show_all_files)
     comment_act = create_action(self, text=_("Show special comments"), toggled=self.toggle_show_comments)
     comment_act.setChecked(self.show_comments)
     actions = [fullpath_act, allfiles_act, comment_act, fromcursor_act]
     return actions
示例#34
0
 def create_folder_manage_actions(self, fnames):
     """Return folder management actions"""
     actions = []
     if os.name == "nt":
         _title = _("Open command prompt here")
     else:
         _title = _("Open terminal here")
     action = create_action(self, _title, icon=ima.icon("cmdprompt"), triggered=lambda: self.open_terminal(fnames))
     actions.append(action)
     _title = _("Open Python console here")
     action = create_action(self, _title, icon=ima.icon("python"), triggered=lambda: self.open_interpreter(fnames))
     actions.append(action)
     return actions
示例#35
0
 def setup_common_actions(self):
     """Setup context menu common actions"""
     # Filters
     filters_action = create_action(self, _("Edit filename filters..."),
                                    None, get_icon('filter.png'),
                                    triggered=self.edit_filter)
     # Show all files
     all_action = create_action(self, _("Show all files"),
                                toggled=self.toggle_all)
     all_action.setChecked(self.show_all)
     self.toggle_all(self.show_all)
     
     return [filters_action, all_action]
示例#36
0
 def create_file_manage_actions(self, fnames):
     """Return file management actions"""
     only_files = all([osp.isfile(_fn) for _fn in fnames])
     only_modules = all([osp.splitext(_fn)[1] in ('.py', '.pyw', '.ipy')
                         for _fn in fnames])
     only_notebooks = all([osp.splitext(_fn)[1] == '.ipynb'
                           for _fn in fnames])
     only_valid = all([encoding.is_text_file(_fn) for _fn in fnames])
     run_action = create_action(self, _("Run"), icon="run_small.png",
                                triggered=self.run)
     edit_action = create_action(self, _("Edit"), icon="edit.png",
                                 triggered=self.clicked)
     move_action = create_action(self, _("Move..."),
                                 icon="move.png",
                                 triggered=self.move)
     delete_action = create_action(self, _("Delete..."),
                                   icon="delete.png",
                                   triggered=self.delete)
     rename_action = create_action(self, _("Rename..."),
                                   icon="rename.png",
                                   triggered=self.rename)
     open_action = create_action(self, _("Open"), triggered=self.open)
     ipynb_convert_action = create_action(self, _("Convert to Python script"),
                                          icon="python.png",
                                          triggered=self.convert)
     
     actions = []
     if only_modules:
         actions.append(run_action)
     if only_valid and only_files:
         actions.append(edit_action)
     else:
         actions.append(open_action)
     actions += [delete_action, rename_action]
     basedir = fixpath(osp.dirname(fnames[0]))
     if all([fixpath(osp.dirname(_fn)) == basedir for _fn in fnames]):
         actions.append(move_action)
     actions += [None]
     if only_notebooks and nbexporter is not None:
         actions.append(ipynb_convert_action)
     
     # VCS support is quite limited for now, so we are enabling the VCS
     # related actions only when a single file/folder is selected:
     dirname = fnames[0] if osp.isdir(fnames[0]) else osp.dirname(fnames[0])
     if len(fnames) == 1 and vcs.is_vcs_repository(dirname):
         vcs_ci = create_action(self, _("Commit"),
                                icon="vcs_commit.png",
                                triggered=lambda fnames=[dirname]:
                                self.vcs_command(fnames, 'commit'))
         vcs_log = create_action(self, _("Browse repository"),
                                 icon="vcs_browse.png",
                                 triggered=lambda fnames=[dirname]:
                                 self.vcs_command(fnames, 'browse'))
         actions += [None, vcs_ci, vcs_log]
     
     return actions
示例#37
0
 def create_file_manage_actions(self, fnames):
     """Return file management actions"""
     only_files = all([osp.isfile(_fn) for _fn in fnames])
     only_modules = all([osp.splitext(_fn)[1] in ('.py', '.pyw', '.ipy')
                         for _fn in fnames])
     only_notebooks = all([osp.splitext(_fn)[1] == '.ipynb'
                           for _fn in fnames])
     only_valid = all([encoding.is_text_file(_fn) for _fn in fnames])
     run_action = create_action(self, _("Run"), icon=ima.icon('run'),
                                triggered=self.run)
     edit_action = create_action(self, _("Edit"), icon=ima.icon('edit'),
                                 triggered=self.clicked)
     move_action = create_action(self, _("Move..."),
                                 icon="move.png",
                                 triggered=self.move)
     delete_action = create_action(self, _("Delete..."),
                                   icon=ima.icon('editdelete'),
                                   triggered=self.delete)
     rename_action = create_action(self, _("Rename..."),
                                   icon=ima.icon('rename'),
                                   triggered=self.rename)
     open_action = create_action(self, _("Open"), triggered=self.open)
     ipynb_convert_action = create_action(self, _("Convert to Python script"),
                                          icon=ima.icon('python'),
                                          triggered=self.convert_notebooks)
     
     actions = []
     if only_modules:
         actions.append(run_action)
     if only_valid and only_files:
         actions.append(edit_action)
     else:
         actions.append(open_action)
     actions += [delete_action, rename_action]
     basedir = fixpath(osp.dirname(fnames[0]))
     if all([fixpath(osp.dirname(_fn)) == basedir for _fn in fnames]):
         actions.append(move_action)
     actions += [None]
     if only_notebooks and nbexporter is not None:
         actions.append(ipynb_convert_action)
     
     # VCS support is quite limited for now, so we are enabling the VCS
     # related actions only when a single file/folder is selected:
     dirname = fnames[0] if osp.isdir(fnames[0]) else osp.dirname(fnames[0])
     if len(fnames) == 1 and vcs.is_vcs_repository(dirname):
         vcs_ci = create_action(self, _("Commit"),
                                icon=ima.icon('vcs_commit'),
                                triggered=lambda fnames=[dirname]:
                                self.vcs_command(fnames, 'commit'))
         vcs_log = create_action(self, _("Browse repository"),
                                 icon=ima.icon('vcs_browse'),
                                 triggered=lambda fnames=[dirname]:
                                 self.vcs_command(fnames, 'browse'))
         actions += [None, vcs_ci, vcs_log]
     
     return actions
示例#38
0
    def get_plugin_actions(self):
        """Return a list of actions related to plugin"""
        new_project_act = create_action(self, text=_('New project...'),
                                        icon=get_icon('project_expanded.png'),
                                        triggered=self.create_new_project)

        font_action = create_action(self, _("&Font..."),
                                    None, 'font.png', _("Set font style"),
                                    triggered=self.change_font)
        self.treewidget.common_actions += (None, font_action)
        
        self.main.file_menu_actions.insert(1, new_project_act)
        
        return []
示例#39
0
 def get_plugin_actions(self):
     """Setup actions"""
     history_action = create_action(self, self.tr("History..."),
                                    None, 'history.png',
                                    self.tr("Set history maximum entries"),
                                    triggered=self.change_history_depth)
     font_action = create_action(self, self.tr("&Font..."), None,
                                 'font.png', self.tr("Set shell font style"),
                                 triggered=self.change_font)
     wrap_action = create_action(self, self.tr("Wrap lines"),
                                 toggled=self.toggle_wrap_mode)
     wrap_action.setChecked( CONF.get(self.ID, 'wrap') )
     self.menu_actions = [history_action, font_action, wrap_action]
     return (self.menu_actions, None)
示例#40
0
文件: __init__.py 项目: G-VAR/spyder
 def create_toggle_view_action(self):
     """Associate a toggle view action with each plugin"""
     title = self.get_plugin_title()
     if self.CONF_SECTION == 'editor':
         title = _('Editor')
     if self.shortcut is not None:
         action = create_action(self, title,
                          toggled=lambda checked: self.toggle_view(checked),
                          shortcut=QKeySequence(self.shortcut),
                          context=Qt.WidgetShortcut)
     else:
         action = create_action(self, title, toggled=lambda checked:
                                             self.toggle_view(checked))
     self.toggle_view_action = action
示例#41
0
    def get_plugin_actions(self):
        """Return a list of actions related to plugin"""
        new_project_act = create_action(self, text=_('New project...'),
                                        icon=ima.icon('project_expanded'),
                                        triggered=self.create_new_project)

        font_action = create_action(self, _("&Font..."),
                                    None, ima.icon('font'), _("Set font style"),
                                    triggered=self.change_font)
        self.treewidget.common_actions += (None, font_action)
        
        self.main.file_menu_actions.insert(1, new_project_act)
        
        return []
示例#42
0
 def create_toggle_view_action(self):
     """Associate a toggle view action with each plugin"""
     title = self.get_plugin_title()
     if self.CONF_SECTION == 'editor':
         title = _('Editor')
     if self.shortcut is not None:
         action = create_action(self,
                                title,
                                toggled=self.toggle_view,
                                shortcut=QKeySequence(self.shortcut))
         action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
     else:
         action = create_action(self, title, toggled=self.toggle_view)
     self.toggle_view_action = action
示例#43
0
文件: history.py 项目: wodole/spyder
 def get_plugin_actions(self):
     """Return a list of actions related to plugin"""
     history_action = create_action(self,
                                    _("History..."),
                                    None,
                                    ima.icon('history'),
                                    _("Set history maximum entries"),
                                    triggered=self.change_history_depth)
     self.wrap_action = create_action(self,
                                      _("Wrap lines"),
                                      toggled=self.toggle_wrap_mode)
     self.wrap_action.setChecked(self.get_option('wrap'))
     self.menu_actions = [history_action, self.wrap_action]
     return self.menu_actions
示例#44
0
 def get_plugin_actions(self):
     """Return a list of actions related to plugin"""
     history_action = create_action(self, _("History..."),
                                    None, 'history.png',
                                    _("Set history maximum entries"),
                                    triggered=self.change_history_depth)
     font_action = create_action(self, _("&Font..."), None,
                                 'font.png', _("Set shell font style"),
                                 triggered=self.change_font)
     self.wrap_action = create_action(self, _("Wrap lines"),
                                 toggled=self.toggle_wrap_mode)
     self.wrap_action.setChecked( self.get_option('wrap') )
     self.menu_actions = [history_action, font_action, self.wrap_action]
     return self.menu_actions
示例#45
0
    def __init__(self,
                 parent=None,
                 show_fullpath=True,
                 fullpath_sorting=True,
                 show_all_files=True,
                 show_comments=True):
        QWidget.__init__(self, parent)

        self.treewidget = OutlineExplorerTreeWidget(
            self,
            show_fullpath=show_fullpath,
            fullpath_sorting=fullpath_sorting,
            show_all_files=show_all_files,
            show_comments=show_comments)

        self.visibility_action = create_action(self,
                                               _("Show/hide outline explorer"),
                                               icon='outline_explorer_vis.png',
                                               toggled=self.toggle_visibility)
        self.visibility_action.setChecked(True)

        btn_layout = QHBoxLayout()
        btn_layout.setAlignment(Qt.AlignLeft)
        for btn in self.setup_buttons():
            btn_layout.addWidget(btn)

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addLayout(btn_layout)
        layout.addWidget(self.treewidget)
        self.setLayout(layout)
 def setup_context_menu(self):
     """Reimplement PythonShellWidget method"""
     PythonShellWidget.setup_context_menu(self)
     self.help_action = create_action(self, _("Help..."),
                        icon=get_std_icon('DialogHelpButton'),
                        triggered=self.help)
     self.menu.addAction(self.help_action)
示例#47
0
    def register_plugin(self):
        """Register plugin in Spyder's main window"""
        self.connect(self, SIGNAL("edit_goto(QString,int,QString)"),
                     self.main.editor.load)
        self.connect(self, SIGNAL('redirect_stdio(bool)'),
                     self.main.redirect_internalshell_stdio)
        self.main.add_dockwidget(self)

        s2pwp_act = create_action(self,
                                  _("Import SED-ML as PhrasedML"),
                                  triggered=self.run_s2pwp)
        s2pwp_act.setEnabled(True)
        #self.register_shortcut(s2p_act, context="SED-ML to Python",
        #                       name="Import SED-ML file", default="Alt-I")

        for item in self.main.file_menu_actions:
            try:
                menu_title = item.title()
            except AttributeError:
                pass
            else:
                if not is_text_string(menu_title):  # string is a QString
                    menu_title = to_text_string(menu_title.toUtf8)
                if item.title() == str("Import"):
                    item.addAction(s2pwp_act)
示例#48
0
文件: tabs.py 项目: s-tazawa/crispy
 def update_browse_tabs_menu(self):
     """Update browse tabs menu"""
     self.browse_tabs_menu.clear()
     names = []
     dirnames = []
     for index in range(self.count()):
         if self.menu_use_tooltips:
             text = to_text_string(self.tabToolTip(index))
         else:
             text = to_text_string(self.tabText(index))
         names.append(text)
         if osp.isfile(text):
             # Testing if tab names are filenames
             dirnames.append(osp.dirname(text))
     offset = None
     
     # If tab names are all filenames, removing common path:
     if len(names) == len(dirnames):
         common = get_common_path(dirnames)
         if common is None:
             offset = None
         else:
             offset = len(common)+1
             if offset <= 3:
                 # Common path is not a path but a drive letter...
                 offset = None
             
     for index, text in enumerate(names):
         tab_action = create_action(self, text[offset:],
                                    icon=self.tabIcon(index),
                                    toggled=lambda state, index=index:
                                            self.setCurrentIndex(index),
                                    tip=self.tabToolTip(index))
         tab_action.setChecked(index == self.currentIndex())
         self.browse_tabs_menu.addAction(tab_action)
示例#49
0
 def create_toggle_view_action(self):
     """Associate a toggle view action with each plugin"""
     title = self.get_plugin_title()
     if self.CONF_SECTION == 'editor':
         title = _('Editor')
     if self.shortcut is not None:
         action = create_action(
             self,
             title,
             toggled=lambda checked: self.toggle_view(checked),
             shortcut=QKeySequence(self.shortcut),
             context=Qt.WidgetShortcut)
     else:
         action = create_action(
             self, title, toggled=lambda checked: self.toggle_view(checked))
     self.toggle_view_action = action
示例#50
0
 def create_toggle_view_action(self):
     """Associate a toggle view action with each plugin"""
     title = self.get_plugin_title()
     if self.CONF_SECTION == 'editor':
         title = _('Editor')
     action = create_action(self, title, toggled=self.toggle_view)
     self.toggle_view_action = action
示例#51
0
 def get_actions_from_items(self, items):
     """Reimplemented OneColumnTree method"""
     fromcursor_act = create_action(self, text=_('Go to cursor position'),
                     icon=ima.icon('fromcursor'),
                     triggered=self.go_to_cursor_position)
     fullpath_act = create_action(self, text=_( 'Show absolute path'),
                     toggled=self.toggle_fullpath_mode)
     fullpath_act.setChecked(self.show_fullpath)
     allfiles_act = create_action(self, text=_( 'Show all files'),
                     toggled=self.toggle_show_all_files)
     allfiles_act.setChecked(self.show_all_files)
     comment_act = create_action(self, text=_('Show special comments'),
                     toggled=self.toggle_show_comments)
     comment_act.setChecked(self.show_comments)
     actions = [fullpath_act, allfiles_act, comment_act, fromcursor_act]
     return actions
示例#52
0
    def register_plugin(self):
        """Register plugin in Spyder's main window"""
        self.connect(self, SIGNAL("edit_goto(QString,int,QString)"),
                     self.main.editor.load)
        self.connect(self, SIGNAL('redirect_stdio(bool)'),
                     self.main.redirect_internalshell_stdio)
        self.main.add_dockwidget(self)

        c2p_act = create_action(self,
                                _("Import COMBINE as Python"),
                                triggered=self.run_c2p)
        c2p_act.setEnabled(True)
        #self.register_shortcut(c2p_act, context="Combine to Python",
        #                       name="Import combine archive", default="Alt-C")
        for item in self.main.file_menu_actions:
            try:
                menu_title = item.title()
            except AttributeError:
                pass
            else:
                if not is_text_string(menu_title):  # string is a QString
                    menu_title = to_text_string(menu_title.toUtf8)
                if item.title() == str("Import"):
                    item.addAction(c2p_act)
        c2p_actions = (None, c2p_act)
        import_menu = QMenu(_("Import"))
        add_actions(import_menu, c2p_actions)
        self.main.file_menu_actions.insert(8, import_menu)
示例#53
0
 def set_actions(self):
     """Setup actions"""
     # Font
     history_action = create_action(self,
                                    self.tr("History..."),
                                    None,
                                    'history.png',
                                    self.tr("Set history maximum entries"),
                                    triggered=self.change_history_depth)
     font_action = create_action(self,
                                 translate('Pylint', "&Font..."),
                                 None,
                                 'font.png',
                                 translate("Pylint", "Set font style"),
                                 triggered=self.change_font)
     self.treewidget.common_actions += (None, history_action, font_action)
     return (None, None)
示例#54
0
 def get_plugin_actions(self):
     """Return a list of actions related to plugin"""
     # Font
     font_action = create_action(self, _("&Font..."), None, 'font.png',
                                 _("Set font style"),
                                 triggered=self.change_font)
     self.treewidget.common_actions.append(font_action)
     return []
示例#55
0
 def get_options_menu(self):
     self.show_time_action = create_action(self, _("Show elapsed time"),
                                       toggled=self.set_elapsed_time_visible)
     self.show_time_action.setChecked(self.show_elapsed_time)
     actions = [self.show_time_action]
     if self.menu_actions is not None:
         actions += [None]+self.menu_actions
     return actions
示例#56
0
 def create_folder_manage_actions(self, fnames):
     """Return folder management actions"""
     actions = []
     if os.name == 'nt':
         _title = _("Open command prompt here")
     else:
         _title = _("Open terminal here")
     action = create_action(self, _title, icon="cmdprompt.png",
                            triggered=lambda fnames=fnames:
                            self.open_terminal(fnames))
     actions.append(action)
     _title = _("Open Python console here")
     action = create_action(self, _title, icon="python.png",
                            triggered=lambda fnames=fnames:
                            self.open_interpreter(fnames))
     actions.append(action)
     return actions