Beispiel #1
0
    def __init__(self,
                 parent,
                 search_text=r"# ?TODO|# ?FIXME|# ?XXX",
                 search_text_regexp=True,
                 search_path=None,
                 include=[".", ".py"],
                 include_idx=None,
                 include_regexp=True,
                 exclude=r"\.pyc$|\.orig$|\.hg|\.svn",
                 exclude_idx=None,
                 exclude_regexp=True,
                 supported_encodings=("utf-8", "iso-8859-1", "cp1252"),
                 in_python_path=False,
                 more_options=False):
        QWidget.__init__(self, parent)

        self.setWindowTitle(_('Find in files'))

        self.search_thread = None
        self.get_pythonpath_callback = None

        self.find_options = FindOptions(self, search_text, search_text_regexp,
                                        search_path, include, include_idx,
                                        include_regexp, exclude, exclude_idx,
                                        exclude_regexp, supported_encodings,
                                        in_python_path, more_options)
        self.find_options.find.connect(self.find)
        self.find_options.stop.connect(self.stop_and_reset_thread)

        self.result_browser = ResultsBrowser(self)

        collapse_btn = create_toolbutton(self)
        collapse_btn.setDefaultAction(self.result_browser.collapse_all_action)
        expand_btn = create_toolbutton(self)
        expand_btn.setDefaultAction(self.result_browser.expand_all_action)
        restore_btn = create_toolbutton(self)
        restore_btn.setDefaultAction(self.result_browser.restore_action)
        #        collapse_sel_btn = create_toolbutton(self)
        #        collapse_sel_btn.setDefaultAction(
        #                                self.result_browser.collapse_selection_action)
        #        expand_sel_btn = create_toolbutton(self)
        #        expand_sel_btn.setDefaultAction(
        #                                self.result_browser.expand_selection_action)

        btn_layout = QVBoxLayout()
        btn_layout.setAlignment(Qt.AlignTop)
        for widget in [collapse_btn, expand_btn, restore_btn]:
            #                       collapse_sel_btn, expand_sel_btn]:
            btn_layout.addWidget(widget)

        hlayout = QHBoxLayout()
        hlayout.addWidget(self.result_browser)
        hlayout.addLayout(btn_layout)

        layout = QVBoxLayout()
        left, _x, right, bottom = layout.getContentsMargins()
        layout.setContentsMargins(left, 0, right, bottom)
        layout.addWidget(self.find_options)
        layout.addLayout(hlayout)
        self.setLayout(layout)
Beispiel #2
0
 def get_toolbar_buttons(self):
     ExternalShellBase.get_toolbar_buttons(self)
     if self.namespacebrowser_button is None \
        and self.stand_alone is not None:
         self.namespacebrowser_button = create_toolbutton(
             self,
             text=_("Variables"),
             icon=get_icon('dictedit.png'),
             tip=_("Show/hide global variables explorer"),
             toggled=self.toggle_globals_explorer,
             text_beside_icon=True)
     if self.terminate_button is None:
         self.terminate_button = create_toolbutton(
             self,
             text=_("Terminate"),
             icon=get_icon('stop.png'),
             tip=_("Attempts to stop the process. The process\n"
                   "may not exit as a result of clicking this\n"
                   "button (it is given the chance to prompt\n"
                   "the user for any unsaved files, etc)."))
     buttons = []
     if self.namespacebrowser_button is not None:
         buttons.append(self.namespacebrowser_button)
     buttons += [
         self.run_button, self.terminate_button, self.kill_button,
         self.options_button
     ]
     return buttons
Beispiel #3
0
 def get_toolbar_buttons(self):
     ExternalShellBase.get_toolbar_buttons(self)
     if self.namespacebrowser_button is None and self.stand_alone:
         self.namespacebrowser_button = create_toolbutton(self,
                       get_icon('dictedit.png'), self.tr("Variables"),
                       tip=self.tr("Show/hide global variables explorer"),
                       toggled=self.toggle_globals_explorer)
     if self.cwd_button is None:
         self.cwd_button = create_toolbutton(self,
                       get_std_icon('DirOpenIcon'), self.tr("Working directory"),
                       tip=self.tr("Set current working directory"),
                       triggered=self.set_current_working_directory)
     if self.terminate_button is None:
         self.terminate_button = create_toolbutton(self,
                       get_icon('terminate.png'), self.tr("Terminate"),
                       tip=self.tr("Attempts to terminate the process.\n"
                                   "The process may not exit as a result of "
                                   "clicking this button\n"
                                   "(it is given the chance to prompt "
                                   "the user for any unsaved files, etc)."))        
     buttons = [self.cwd_button]
     if self.namespacebrowser_button is not None:
         buttons.append(self.namespacebrowser_button)
     buttons += [self.run_button, self.options_button,
                 self.terminate_button, self.kill_button]
     return buttons
Beispiel #4
0
 def get_toolbar_buttons(self):
     if self.run_button is None:
         self.run_button = create_toolbutton(self, get_icon('run.png'),
                           translate('ExternalShellBase', "Run"),
                           tip=translate('ExternalShellBase',
                                         "Run again this program"),
                           triggered=self.start)
     if self.kill_button is None:
         self.kill_button = create_toolbutton(self, get_icon('kill.png'),
                           translate('ExternalShellBase', "Kill"),
                           tip=translate('ExternalShellBase',
                                         "Kills the current process, "
                                         "causing it to exit immediately"))
     buttons = [self.run_button, self.kill_button]
     if self.options_button is None:
         options = self.get_options_menu()
         if options:
             self.options_button = create_toolbutton(self,
                                         text=self.tr("Options"),
                                         icon=get_icon('tooloptions.png'))
             self.options_button.setPopupMode(QToolButton.InstantPopup)
             menu = QMenu(self)
             add_actions(menu, options)
             self.options_button.setMenu(menu)
     if self.options_button is not None:
         buttons.insert(1, self.options_button)
     return buttons
Beispiel #5
0
 def setup_bottom_toolbar(self, layout, sync=True):
     toolbar = []
     add_button = create_toolbutton(self,
                                    text=_('Add path'),
                                    icon=ima.icon('edit_add'),
                                    triggered=self.add_path,
                                    text_beside_icon=True)
     toolbar.append(add_button)
     remove_button = create_toolbutton(self,
                                       text=_('Remove path'),
                                       icon=ima.icon('edit_remove'),
                                       triggered=self.remove_path,
                                       text_beside_icon=True)
     toolbar.append(remove_button)
     self.selection_widgets.append(remove_button)
     self._add_widgets_to_layout(layout, toolbar)
     layout.addStretch(1)
     if os.name == 'nt' and sync:
         self.sync_button = create_toolbutton(
             self,
             text=_("Synchronize..."),
             icon=ima.icon('fileimport'),
             triggered=self.synchronize,
             tip=_("Synchronize Spyder's path list with PYTHONPATH "
                   "environment variable"),
             text_beside_icon=True)
         layout.addWidget(self.sync_button)
     return toolbar
Beispiel #6
0
    def get_toolbar_buttons(self):
        """Return toolbar buttons list"""
        #TODO: Eventually add some buttons (Empty for now)
        # (see for example: spyderlib/widgets/externalshell/baseshell.py)
        buttons = []
        # Code to add the stop button 
        if self.stop_button is None:
            self.stop_button = create_toolbutton(self, text=_("Stop"),
                                             icon=self.stop_icon,
                                             tip=_("Stop the current command"))
            self.disable_stop_button()
            # set click event handler
            self.stop_button.clicked.connect(self.stop_button_click_handler)
        if self.stop_button is not None:
            buttons.append(self.stop_button)
            
        if self.options_button is None:
            options = self.get_options_menu()
            if options:
                self.options_button = create_toolbutton(self,
                        text=_('Options'), icon=ima.icon('tooloptions'))
                self.options_button.setPopupMode(QToolButton.InstantPopup)
                menu = QMenu(self)
                add_actions(menu, options)
                self.options_button.setMenu(menu)
        if self.options_button is not None:
            buttons.append(self.options_button)

        return buttons
Beispiel #7
0
    def get_toolbar_buttons(self):
        """Return toolbar buttons list"""
        #TODO: Eventually add some buttons (Empty for now)
        # (see for example: spyderlib/widgets/externalshell/baseshell.py)
        buttons = []
        # Code to add the stop button
        if self.stop_button is None:
            self.stop_button = create_toolbutton(
                self,
                text=_("Stop"),
                icon=self.stop_icon,
                tip=_("Stop the current command"))
            self.disable_stop_button()
            # set click event handler
            self.stop_button.clicked.connect(self.stop_button_click_handler)
        if self.stop_button is not None:
            buttons.append(self.stop_button)

        if self.options_button is None:
            options = self.get_options_menu()
            if options:
                self.options_button = create_toolbutton(
                    self, text=_("Options"), icon=get_icon('tooloptions.png'))
                self.options_button.setPopupMode(QToolButton.InstantPopup)
                menu = QMenu(self)
                add_actions(menu, options)
                self.options_button.setMenu(menu)
        if self.options_button is not None:
            buttons.append(self.options_button)

        return buttons
 def get_toolbar_buttons(self):
     ExternalShellBase.get_toolbar_buttons(self)
     if self.namespacebrowser_button is None and self.stand_alone is not None:
         self.namespacebrowser_button = create_toolbutton(
             self,
             text=_("Variables"),
             icon=get_icon("dictedit.png"),
             tip=_("Show/hide global variables explorer"),
             toggled=self.toggle_globals_explorer,
             text_beside_icon=True,
         )
     if self.terminate_button is None:
         self.terminate_button = create_toolbutton(
             self,
             text=_("Terminate"),
             icon=get_icon("stop.png"),
             tip=_(
                 "Attempts to stop the process. The process\n"
                 "may not exit as a result of clicking this\n"
                 "button (it is given the chance to prompt\n"
                 "the user for any unsaved files, etc)."
             ),
         )
     buttons = []
     if self.namespacebrowser_button is not None:
         buttons.append(self.namespacebrowser_button)
     buttons += [self.run_button, self.terminate_button, self.kill_button, self.options_button]
     return buttons
Beispiel #9
0
 def get_toolbar_buttons(self):
     if self.run_button is None:
         self.run_button = create_toolbutton(
             self, text=_("Run"), icon=ima.icon("run"), tip=_("Run again this program"), triggered=self.start_shell
         )
     if self.kill_button is None:
         self.kill_button = create_toolbutton(
             self,
             text=_("Kill"),
             icon=ima.icon("kill"),
             tip=_("Kills the current process, " "causing it to exit immediately"),
         )
     buttons = [self.run_button]
     if self.options_button is None:
         options = self.get_options_menu()
         if options:
             self.options_button = create_toolbutton(self, text=_("Options"), icon=ima.icon("tooloptions"))
             self.options_button.setPopupMode(QToolButton.InstantPopup)
             menu = QMenu(self)
             add_actions(menu, options)
             self.options_button.setMenu(menu)
     if self.options_button is not None:
         buttons.append(self.options_button)
     buttons.append(self.kill_button)
     return buttons
Beispiel #10
0
 def setup_top_toolbar(self, layout):
     toolbar = []
     movetop_button = create_toolbutton(self,
                                 text=_("Move to top"),
                                 icon=get_icon('2uparrow.png'),
                                 triggered=lambda: self.move_to(absolute=0),
                                 text_beside_icon=True)
     toolbar.append(movetop_button)
     moveup_button = create_toolbutton(self,
                                 text=_("Move up"),
                                 icon=get_icon('1uparrow.png'),
                                 triggered=lambda: self.move_to(relative=-1),
                                 text_beside_icon=True)
     toolbar.append(moveup_button)
     movedown_button = create_toolbutton(self,
                                 text=_("Move down"),
                                 icon=get_icon('1downarrow.png'),
                                 triggered=lambda: self.move_to(relative=1),
                                 text_beside_icon=True)
     toolbar.append(movedown_button)
     movebottom_button = create_toolbutton(self,
                                 text=_("Move to bottom"),
                                 icon=get_icon('2downarrow.png'),
                                 triggered=lambda: self.move_to(absolute=1),
                                 text_beside_icon=True)
     toolbar.append(movebottom_button)
     self.selection_widgets.extend(toolbar)
     self._add_widgets_to_layout(layout, toolbar)
     return toolbar
Beispiel #11
0
 def setup_bottom_toolbar(self, layout):
     toolbar = []
     add_button = create_toolbutton(self,
                                    text=self.tr("Add path"),
                                    icon=get_icon('edit_add.png'),
                                    triggered=self.add_path)
     toolbar.append(add_button)
     remove_button = create_toolbutton(self,
                                       text=self.tr("Remove path"),
                                       icon=get_icon('edit_remove.png'),
                                       triggered=self.remove_path)
     toolbar.append(remove_button)
     self.selection_widgets.append(remove_button)
     self._add_widgets_to_layout(layout, toolbar)
     layout.addStretch(1)
     if os.name == 'nt':
         self.sync_button = create_toolbutton(
             self,
             text=self.tr("Synchronize..."),
             icon=get_icon('synchronize.png'),
             triggered=self.synchronize,
             tip=self.tr("Synchronize Spyder's path list with PYTHONPATH "
                         "environment variable"))
         layout.addWidget(self.sync_button)
     return toolbar
Beispiel #12
0
 def setup_bottom_toolbar(self, layout, sync=True):
     toolbar = []
     add_button = create_toolbutton(
         self, text=_("Add path"), icon=get_icon("edit_add.png"), triggered=self.add_path, text_beside_icon=True
     )
     toolbar.append(add_button)
     remove_button = create_toolbutton(
         self,
         text=_("Remove path"),
         icon=get_icon("edit_remove.png"),
         triggered=self.remove_path,
         text_beside_icon=True,
     )
     toolbar.append(remove_button)
     self.selection_widgets.append(remove_button)
     self._add_widgets_to_layout(layout, toolbar)
     layout.addStretch(1)
     if os.name == "nt" and sync:
         self.sync_button = create_toolbutton(
             self,
             text=_("Synchronize..."),
             icon=get_icon("synchronize.png"),
             triggered=self.synchronize,
             tip=_("Synchronize Spyder's path list with PYTHONPATH " "environment variable"),
             text_beside_icon=True,
         )
         layout.addWidget(self.sync_button)
     return toolbar
Beispiel #13
0
 def get_toolbar_buttons(self):
     if self.run_button is None:
         self.run_button = create_toolbutton(
             self,
             text=_("Run"),
             icon=get_icon('run.png'),
             tip=_("Run again this program"),
             triggered=self.start_shell)
     if self.kill_button is None:
         self.kill_button = create_toolbutton(
             self,
             text=_("Kill"),
             icon=get_icon('kill.png'),
             tip=_("Kills the current process, "
                   "causing it to exit immediately"))
     buttons = [self.run_button]
     if self.options_button is None:
         options = self.get_options_menu()
         if options:
             self.options_button = create_toolbutton(
                 self, text=_("Options"), icon=get_icon('tooloptions.png'))
             self.options_button.setPopupMode(QToolButton.InstantPopup)
             menu = QMenu(self)
             add_actions(menu, options)
             self.options_button.setMenu(menu)
     if self.options_button is not None:
         buttons.append(self.options_button)
     buttons.append(self.kill_button)
     return buttons
Beispiel #14
0
 def setup_top_toolbar(self, layout):
     toolbar = []
     movetop_button = create_toolbutton(self,
                                 text=_("Move to top"),
                                 icon=get_icon('2uparrow.png'),
                                 triggered=lambda: self.move_to(absolute=0),
                                 text_beside_icon=True)
     toolbar.append(movetop_button)
     moveup_button = create_toolbutton(self,
                                 text=_("Move up"),
                                 icon=get_icon('1uparrow.png'),
                                 triggered=lambda: self.move_to(relative=-1),
                                 text_beside_icon=True)
     toolbar.append(moveup_button)
     movedown_button = create_toolbutton(self,
                                 text=_("Move down"),
                                 icon=get_icon('1downarrow.png'),
                                 triggered=lambda: self.move_to(relative=1),
                                 text_beside_icon=True)
     toolbar.append(movedown_button)
     movebottom_button = create_toolbutton(self,
                                 text=_("Move to bottom"),
                                 icon=get_icon('2downarrow.png'),
                                 triggered=lambda: self.move_to(absolute=1),
                                 text_beside_icon=True)
     toolbar.append(movebottom_button)
     self.selection_widgets.extend(toolbar)
     self._add_widgets_to_layout(layout, toolbar)
     return toolbar
Beispiel #15
0
    def __init__(self, parent,
                 search_text = r"# ?TODO|# ?FIXME|# ?XXX",
                 search_text_regexp=True, search_path=None,
                 include=[".", ".py"], include_idx=None, include_regexp=True,
                 exclude=r"\.pyc$|\.orig$|\.hg|\.svn", exclude_idx=None,
                 exclude_regexp=True,
                 supported_encodings=("utf-8", "iso-8859-1", "cp1252"),
                 in_python_path=False, more_options=False):
        QWidget.__init__(self, parent)
        
        self.setWindowTitle(_('Find in files'))

        self.search_thread = None
        self.get_pythonpath_callback = None
        
        self.find_options = FindOptions(self, search_text, search_text_regexp,
                                        search_path,
                                        include, include_idx, include_regexp,
                                        exclude, exclude_idx, exclude_regexp,
                                        supported_encodings, in_python_path,
                                        more_options)
        self.connect(self.find_options, SIGNAL('find()'), self.find)
        self.connect(self.find_options, SIGNAL('stop()'),
                     self.stop_and_reset_thread)
        
        self.result_browser = ResultsBrowser(self)
        
        collapse_btn = create_toolbutton(self)
        collapse_btn.setDefaultAction(self.result_browser.collapse_all_action)
        expand_btn = create_toolbutton(self)
        expand_btn.setDefaultAction(self.result_browser.expand_all_action)
        restore_btn = create_toolbutton(self)
        restore_btn.setDefaultAction(self.result_browser.restore_action)
#        collapse_sel_btn = create_toolbutton(self)
#        collapse_sel_btn.setDefaultAction(
#                                self.result_browser.collapse_selection_action)
#        expand_sel_btn = create_toolbutton(self)
#        expand_sel_btn.setDefaultAction(
#                                self.result_browser.expand_selection_action)
        
        btn_layout = QVBoxLayout()
        btn_layout.setAlignment(Qt.AlignTop)
        for widget in [collapse_btn, expand_btn, restore_btn]:
#                       collapse_sel_btn, expand_sel_btn]:
            btn_layout.addWidget(widget)
        
        hlayout = QHBoxLayout()
        hlayout.addWidget(self.result_browser)
        hlayout.addLayout(btn_layout)
        
        layout = QVBoxLayout()
        left, _x, right, bottom = layout.getContentsMargins()
        layout.setContentsMargins(left, 0, right, bottom)
        layout.addWidget(self.find_options)
        layout.addLayout(hlayout)
        self.setLayout(layout)
Beispiel #16
0
    def __init__(self,
                 parent,
                 search_text=r"# ?TODO|# ?FIXME|# ?XXX",
                 search_text_regexp=True,
                 search_path=None,
                 include=".",
                 include_regexp=True,
                 exclude=r"\.pyc$|\.orig$|\.hg|\.svn",
                 exclude_regexp=True,
                 supported_encodings=("utf-8", "iso-8859-1", "cp1252")):
        QWidget.__init__(self, parent)

        self.search_thread = SearchThread(self)
        self.connect(self.search_thread, SIGNAL("finished()"),
                     self.search_complete)

        self.find_options = FindOptions(self, search_text, search_text_regexp,
                                        search_path, include, include_regexp,
                                        exclude, exclude_regexp,
                                        supported_encodings)
        self.connect(self.find_options, SIGNAL('find()'), self.find)
        self.connect(self.find_options, SIGNAL('stop()'), self.stop)

        self.result_browser = ResultsBrowser(self)

        collapse_btn = create_toolbutton(
            self,
            get_icon("collapse.png"),
            tip=translate('FindInFiles', "Collapse all"),
            triggered=self.result_browser.collapseAll)
        expand_btn = create_toolbutton(self,
                                       get_icon("expand.png"),
                                       tip=translate('FindInFiles',
                                                     "Expand all"),
                                       triggered=self.result_browser.expandAll)
        restore_btn = create_toolbutton(self,
                                        get_icon("restore.png"),
                                        tip=translate(
                                            'FindInFiles',
                                            "Restore original tree layout"),
                                        triggered=self.result_browser.restore)
        btn_layout = QVBoxLayout()
        btn_layout.setAlignment(Qt.AlignTop)
        for widget in [collapse_btn, expand_btn, restore_btn]:
            btn_layout.addWidget(widget)

        hlayout = QHBoxLayout()
        hlayout.addWidget(self.result_browser)
        hlayout.addLayout(btn_layout)

        layout = QVBoxLayout()
        left, _, right, bottom = layout.getContentsMargins()
        layout.setContentsMargins(left, 0, right, bottom)
        layout.addWidget(self.find_options)
        layout.addLayout(hlayout)
        self.setLayout(layout)
Beispiel #17
0
 def get_toolbar_buttons(self):
     self.run_button = create_toolbutton(self, get_icon('run.png'),
                           self.tr("Run"),
                           tip=self.tr("Run again this program"),
                           triggered=self.start)
     self.kill_button = create_toolbutton(self, get_icon('kill.png'),
                           self.tr("Kill"),
                           tip=self.tr("Kills the current process, "
                                       "causing it to exit immediately"))
     return [self.run_button, self.kill_button]
Beispiel #18
0
 def setup_buttons(self):
     fromcursor_btn = create_toolbutton(self, get_icon("fromcursor.png"),
                      tip=translate('ClassBrowser', 'Go to cursor position'),
                      triggered=self.treewidget.go_to_cursor_position)
     collapse_btn = create_toolbutton(self, text_beside_icon=False)
     collapse_btn.setDefaultAction(self.treewidget.collapse_selection_action)
     expand_btn = create_toolbutton(self, text_beside_icon=False)
     expand_btn.setDefaultAction(self.treewidget.expand_selection_action)
     restore_btn = create_toolbutton(self, text_beside_icon=False)
     restore_btn.setDefaultAction(self.treewidget.restore_action)
     return (fromcursor_btn, collapse_btn, expand_btn, restore_btn)
Beispiel #19
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)
Beispiel #20
0
 def setup_buttons(self):
     fromcursor_btn = create_toolbutton(self,
                          icon=get_icon("fromcursor.png"),
                          tip=_('Go to cursor position'),
                          triggered=self.treewidget.go_to_cursor_position)
     collapse_btn = create_toolbutton(self)
     collapse_btn.setDefaultAction(self.treewidget.collapse_selection_action)
     expand_btn = create_toolbutton(self)
     expand_btn.setDefaultAction(self.treewidget.expand_selection_action)
     restore_btn = create_toolbutton(self)
     restore_btn.setDefaultAction(self.treewidget.restore_action)
     return (fromcursor_btn, collapse_btn, expand_btn, restore_btn)
Beispiel #21
0
 def setup_buttons(self):
     fromcursor_btn = create_toolbutton(self,
                          icon=ima.icon('fromcursor'),
                          tip=_('Go to cursor position'),
                          triggered=self.treewidget.go_to_cursor_position)
     collapse_btn = create_toolbutton(self)
     collapse_btn.setDefaultAction(self.treewidget.collapse_selection_action)
     expand_btn = create_toolbutton(self)
     expand_btn.setDefaultAction(self.treewidget.expand_selection_action)
     restore_btn = create_toolbutton(self)
     restore_btn.setDefaultAction(self.treewidget.restore_action)
     return (fromcursor_btn, collapse_btn, expand_btn, restore_btn)
Beispiel #22
0
    def __init__(self, parent):
        self.tabwidget = None
        self.menu_actions = None
        self.dockviewer = None
        
        self.editors = []
        self.filenames = []
        self.icons = []
        
        SpyderPluginWidget.__init__(self, parent)
        
        layout = QVBoxLayout()
        self.tabwidget = Tabs(self, self.menu_actions)
        self.connect(self.tabwidget, SIGNAL('currentChanged(int)'),
                     self.refresh_plugin)
        self.connect(self.tabwidget, SIGNAL('move_data(int,int)'),
                     self.move_tab)
        layout.addWidget(self.tabwidget)

        # Menu as corner widget
        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, self.menu_actions)
        options_button.setMenu(menu)
        self.tabwidget.setCornerWidget(options_button)
        
        # Find/replace widget
        self.find_widget = FindReplace(self)
        self.find_widget.hide()
        layout.addWidget(self.find_widget)
        
        self.setLayout(layout)
Beispiel #23
0
    def __init__(self, parent, actions=None, menu=None,
                 corner_widgets=None, menu_use_tooltips=False):
        QTabWidget.__init__(self, parent)
        self.setUsesScrollButtons(True)

        # To style tabs on Mac
        if sys.platform == 'darwin':
            self.setObjectName('plugin-tab')

        self.corner_widgets = {}
        self.menu_use_tooltips = menu_use_tooltips
        
        if menu is None:
            self.menu = QMenu(self)
            if actions:
                add_actions(self.menu, actions)
        else:
            self.menu = menu
            
        # Corner widgets
        if corner_widgets is None:
            corner_widgets = {}
        corner_widgets.setdefault(Qt.TopLeftCorner, [])
        corner_widgets.setdefault(Qt.TopRightCorner, [])
        self.browse_button = create_toolbutton(self,
                                          icon=ima.icon('browse_tab'),
                                          tip=_("Browse tabs"))
        self.browse_tabs_menu = QMenu(self)
        self.browse_button.setMenu(self.browse_tabs_menu)
        self.browse_button.setPopupMode(self.browse_button.InstantPopup)
        self.browse_tabs_menu.aboutToShow.connect(self.update_browse_tabs_menu)
        corner_widgets[Qt.TopLeftCorner] += [self.browse_button]

        self.set_corner_widgets(corner_widgets)
Beispiel #24
0
    def __init__(self,
                 parent,
                 actions=None,
                 menu=None,
                 corner_widgets=None,
                 menu_use_tooltips=False):
        QTabWidget.__init__(self, parent)

        self.setUsesScrollButtons(True)

        self.corner_widgets = {}
        self.menu_use_tooltips = menu_use_tooltips

        if menu is None:
            self.menu = QMenu(self)
            if actions:
                add_actions(self.menu, actions)
        else:
            self.menu = menu

        # Corner widgets
        if corner_widgets is None:
            corner_widgets = {}
        corner_widgets.setdefault(Qt.TopLeftCorner, [])
        corner_widgets.setdefault(Qt.TopRightCorner, [])
        self.browse_button = create_toolbutton(self,
                                               icon=get_icon("browse_tab.png"),
                                               tip=_("Browse tabs"))
        self.browse_tabs_menu = QMenu(self)
        self.browse_button.setMenu(self.browse_tabs_menu)
        self.browse_button.setPopupMode(self.browse_button.InstantPopup)
        self.browse_tabs_menu.aboutToShow.connect(self.update_browse_tabs_menu)
        corner_widgets[Qt.TopLeftCorner] += [self.browse_button]

        self.set_corner_widgets(corner_widgets)
Beispiel #25
0
    def __init__(self, parent, actions=None, menu=None,
                 corner_widgets=None, menu_use_tooltips=False):
        QTabWidget.__init__(self, parent)
        self.setUsesScrollButtons(True)

        # To style tabs on Mac
        if sys.platform == 'darwin':
            self.setObjectName('plugin-tab')

        self.corner_widgets = {}
        self.menu_use_tooltips = menu_use_tooltips
        
        if menu is None:
            self.menu = QMenu(self)
            if actions:
                add_actions(self.menu, actions)
        else:
            self.menu = menu
            
        # Corner widgets
        if corner_widgets is None:
            corner_widgets = {}
        corner_widgets.setdefault(Qt.TopLeftCorner, [])
        corner_widgets.setdefault(Qt.TopRightCorner, [])
        self.browse_button = create_toolbutton(self,
                                          icon=ima.icon('browse_tab'),
                                          tip=_("Browse tabs"))
        self.browse_tabs_menu = QMenu(self)
        self.browse_button.setMenu(self.browse_tabs_menu)
        self.browse_button.setPopupMode(self.browse_button.InstantPopup)
        self.browse_tabs_menu.aboutToShow.connect(self.update_browse_tabs_menu)
        corner_widgets[Qt.TopLeftCorner] += [self.browse_button]

        self.set_corner_widgets(corner_widgets)
Beispiel #26
0
    def __init__(self, parent, actions=None, menu=None,
                 corner_widgets=None, menu_use_tooltips=False):
        QTabWidget.__init__(self, parent)
        
        self.setUsesScrollButtons(True)
        
        self.corner_widgets = {}
        self.menu_use_tooltips = menu_use_tooltips
        
        if menu is None:
            self.menu = QMenu(self)
            if actions:
                add_actions(self.menu, actions)
        else:
            self.menu = menu
            
        # Corner widgets
        if corner_widgets is None:
            corner_widgets = {}
        corner_widgets.setdefault(Qt.TopLeftCorner, [])
        corner_widgets.setdefault(Qt.TopRightCorner, [])
        self.browse_button = create_toolbutton(self,
                                          icon=get_icon("browse_tab.png"),
                                          tip=_("Browse tabs"))
        self.browse_tabs_menu = QMenu(self)
        self.browse_button.setMenu(self.browse_tabs_menu)
        self.browse_button.setPopupMode(self.browse_button.InstantPopup)
        self.browse_tabs_menu.aboutToShow.connect(self.update_browse_tabs_menu)
        corner_widgets[Qt.TopLeftCorner] += [self.browse_button]

        self.set_corner_widgets(corner_widgets)
Beispiel #27
0
    def __init__(self, parent,
                 search_text = r"# ?TODO|# ?FIXME|# ?XXX",
                 search_text_regexp=True, search_path=None,
                 include=".", include_regexp=True,
                 exclude=r"\.pyc$|\.orig$|\.hg|\.svn", exclude_regexp=True,
                 supported_encodings=("utf-8", "iso-8859-1", "cp1252")):
        QWidget.__init__(self, parent)

        self.search_thread = SearchThread(self)
        self.connect(self.search_thread, SIGNAL("finished()"),
                     self.search_complete)
        
        self.find_options = FindOptions(self, search_text, search_text_regexp,
                                        search_path, include, include_regexp,
                                        exclude, exclude_regexp,
                                        supported_encodings)
        self.connect(self.find_options, SIGNAL('find()'), self.find)
        self.connect(self.find_options, SIGNAL('stop()'), self.stop)
        
        self.result_browser = ResultsBrowser(self)
        
        collapse_btn = create_toolbutton(self, get_icon("collapse.png"),
                                 tip=translate('FindInFiles', "Collapse all"),
                                 triggered=self.result_browser.collapseAll)
        expand_btn = create_toolbutton(self, get_icon("expand.png"),
                                 tip=translate('FindInFiles', "Expand all"),
                                 triggered=self.result_browser.expandAll)
        restore_btn = create_toolbutton(self, get_icon("restore.png"),
                                 tip=translate('FindInFiles',
                                               "Restore original tree layout"),
                                 triggered=self.result_browser.restore)
        btn_layout = QVBoxLayout()
        btn_layout.setAlignment(Qt.AlignTop)
        for widget in [collapse_btn, expand_btn, restore_btn]:
            btn_layout.addWidget(widget)
        
        hlayout = QHBoxLayout()
        hlayout.addWidget(self.result_browser)
        hlayout.addLayout(btn_layout)
        
        layout = QVBoxLayout()
        left, _, right, bottom = layout.getContentsMargins()
        layout.setContentsMargins(left, 0, right, bottom)
        layout.addWidget(self.find_options)
        layout.addLayout(hlayout)
        self.setLayout(layout)
Beispiel #28
0
 def get_toolbar_buttons(self):
     ExternalShellBase.get_toolbar_buttons(self)
     self.globalsexplorer_button = create_toolbutton(self,
                       get_icon('dictedit.png'), self.tr("Variables"),
                       tip=self.tr("Show/hide global variables explorer"),
                       toggled=self.toggle_globals_explorer)
     self.terminate_button = create_toolbutton(self,
           get_icon('terminate.png'), self.tr("Terminate"),
           tip=self.tr("Attempts to terminate the process.\n"
                       "The process may not exit as a result of clicking "
                       "this button\n(it is given the chance to prompt "
                       "the user for any unsaved files, etc)."))        
     self.interact_check = QCheckBox(self.tr("Interact"), self)
     self.debug_check = QCheckBox(self.tr("Debug"), self)
     return [self.interact_check, self.debug_check,
             self.globalsexplorer_button, self.run_button,
             self.terminate_button, self.kill_button]
Beispiel #29
0
    def __init__(self, parent):
        self.tabwidget = None
        self.menu_actions = None
        self.dockviewer = None
        self.wrap_action = None

        self.editors = []
        self.filenames = []
        self.icons = []
        if PYQT5:
            SpyderPluginWidget.__init__(self, parent, main=parent)
        else:
            SpyderPluginWidget.__init__(self, parent)

        # Initialize plugin
        self.initialize_plugin()

        self.set_default_color_scheme()

        layout = QVBoxLayout()
        self.tabwidget = Tabs(self, self.menu_actions)
        self.tabwidget.currentChanged.connect(self.refresh_plugin)
        self.tabwidget.move_data.connect(self.move_tab)

        if sys.platform == 'darwin':
            tab_container = QWidget()
            tab_container.setObjectName('tab-container')
            tab_layout = QHBoxLayout(tab_container)
            tab_layout.setContentsMargins(0, 0, 0, 0)
            tab_layout.addWidget(self.tabwidget)
            layout.addWidget(tab_container)
        else:
            layout.addWidget(self.tabwidget)

        self.tabwidget.setStyleSheet("QTabWidget::pane {border: 0;}")

        # Menu as corner widget
        options_button = create_toolbutton(self,
                                           text=_('Options'),
                                           icon=ima.icon('tooloptions'))
        options_button.setPopupMode(QToolButton.InstantPopup)
        menu = QMenu(self)
        add_actions(menu, self.menu_actions)
        options_button.setMenu(menu)
        self.tabwidget.setCornerWidget(options_button)

        # Find/replace widget
        self.find_widget = FindReplace(self)
        self.find_widget.hide()
        self.register_widget_shortcuts("Editor", self.find_widget)

        layout.addWidget(self.find_widget)

        self.setLayout(layout)
Beispiel #30
0
 def setup_bottom_toolbar(self, layout):
     toolbar = []
     add_button = create_toolbutton(self, text=self.tr("Add path"),
                                    icon=get_icon('edit_add.png'),
                                    triggered=self.add_path)
     toolbar.append(add_button)
     remove_button = create_toolbutton(self, text=self.tr("Remove path"),
                                       icon=get_icon('edit_remove.png'),
                                       triggered=self.remove_path)
     toolbar.append(remove_button)
     self.selection_widgets.append(remove_button)
     self._add_widgets_to_layout(layout, toolbar)
     layout.addStretch(1)
     if os.name == 'nt':
         self.sync_button = create_toolbutton(self,
               text=self.tr("Synchronize..."),
               icon=get_icon('synchronize.png'), triggered=self.synchronize,
               tip=self.tr("Synchronize Spyder's path list with PYTHONPATH "
                           "environment variable"))
         layout.addWidget(self.sync_button)
     return toolbar
Beispiel #31
0
    def __init__(self, parent):
        self.tabwidget = None
        self.menu_actions = None
        self.dockviewer = None
        self.wrap_action = None
        
        self.editors = []
        self.filenames = []
        self.icons = []
        if PYQT5:        
            SpyderPluginWidget.__init__(self, parent, main = parent)
        else:
            SpyderPluginWidget.__init__(self, parent)

        # Initialize plugin
        self.initialize_plugin()
        
        self.set_default_color_scheme()
        
        layout = QVBoxLayout()
        self.tabwidget = Tabs(self, self.menu_actions)
        self.tabwidget.currentChanged.connect(self.refresh_plugin)
        self.tabwidget.move_data.connect(self.move_tab)

        if sys.platform == 'darwin':
            tab_container = QWidget()
            tab_container.setObjectName('tab-container')
            tab_layout = QHBoxLayout(tab_container)
            tab_layout.setContentsMargins(0, 0, 0, 0)
            tab_layout.addWidget(self.tabwidget)
            layout.addWidget(tab_container)
        else:
            layout.addWidget(self.tabwidget)

        self.tabwidget.setStyleSheet("QTabWidget::pane {border: 0;}")

        # Menu as corner widget
        options_button = create_toolbutton(self, text=_('Options'),
                                           icon=ima.icon('tooloptions'))
        options_button.setPopupMode(QToolButton.InstantPopup)
        menu = QMenu(self)
        add_actions(menu, self.menu_actions)
        options_button.setMenu(menu)
        self.tabwidget.setCornerWidget(options_button)
        
        # Find/replace widget
        self.find_widget = FindReplace(self)
        self.find_widget.hide()
        self.register_widget_shortcuts("Editor", self.find_widget)
        
        layout.addWidget(self.find_widget)
        
        self.setLayout(layout)
Beispiel #32
0
 def get_toolbar_buttons(self):
     ExternalShellBase.get_toolbar_buttons(self)
     self.globalsexplorer_button = create_toolbutton(
         self,
         get_icon('dictedit.png'),
         self.tr("Variables"),
         tip=self.tr("Show/hide global variables explorer"),
         toggled=self.toggle_globals_explorer)
     self.terminate_button = create_toolbutton(
         self,
         get_icon('terminate.png'),
         self.tr("Terminate"),
         tip=self.tr("Attempts to terminate the process.\n"
                     "The process may not exit as a result of clicking "
                     "this button\n(it is given the chance to prompt "
                     "the user for any unsaved files, etc)."))
     self.interact_check = QCheckBox(self.tr("Interact"), self)
     self.debug_check = QCheckBox(self.tr("Debug"), self)
     return [
         self.interact_check, self.debug_check, self.globalsexplorer_button,
         self.run_button, self.terminate_button, self.kill_button
     ]
Beispiel #33
0
 def set_close_function(self, func):
     """Setting Tabs close function
     None -> tabs are not closable"""
     state = func is not None
     if state:
         self.sig_close_tab.connect(func)
     try:
         # Assuming Qt >= 4.5
         QTabWidget.setTabsClosable(self, state)
         self.tabCloseRequested.connect(func)
     except AttributeError:
         # Workaround for Qt < 4.5
         close_button = create_toolbutton(self, triggered=func,
                                          icon=ima.icon('fileclose'),
                                          tip=_("Close current tab"))
         self.setCornerWidget(close_button if state else None)
Beispiel #34
0
 def set_close_function(self, func):
     """Setting Tabs close function
     None -> tabs are not closable"""
     state = func is not None
     if state:
         self.sig_close_tab.connect(func)
     try:
         # Assuming Qt >= 4.5
         QTabWidget.setTabsClosable(self, state)
         self.tabCloseRequested.connect(func)
     except AttributeError:
         # Workaround for Qt < 4.5
         close_button = create_toolbutton(self, triggered=func,
                                          icon=ima.icon('fileclose'),
                                          tip=_("Close current tab"))
         self.setCornerWidget(close_button if state else None)
Beispiel #35
0
 def set_close_function(self, func):
     """Setting Tabs close function
     None -> tabs are not closable"""
     state = func is not None
     if state:
         self.connect(self, SIGNAL("close_tab(int)"), func)
     try:
         # Assuming Qt >= 4.5
         QTabWidget.setTabsClosable(self, state)
         self.connect(self, SIGNAL("tabCloseRequested(int)"), func)
     except AttributeError:
         # Workaround for Qt < 4.5
         close_button = create_toolbutton(self, triggered=func,
                                          icon=get_icon("fileclose.png"),
                                          tip=translate("Tabs",
                                                        "Close current tab"))
         self.setCornerWidget(close_button if state else None)
Beispiel #36
0
 def get_toolbar_buttons(self):
     """Return toolbar buttons list"""
     #TODO: Eventually add some buttons (Empty for now)
     # (see for example: spyderlib/widgets/externalshell/baseshell.py)
     buttons = []
     if self.options_button is None:
         options = self.get_options_menu()
         if options:
             self.options_button = create_toolbutton(self,
                     text=_("Options"), icon=get_icon('tooloptions.png'))
             self.options_button.setPopupMode(QToolButton.InstantPopup)
             menu = QMenu(self)
             add_actions(menu, options)
             self.options_button.setMenu(menu)
     if self.options_button is not None:
         buttons.append(self.options_button)
     return buttons
Beispiel #37
0
    def register_editorstack(self, editorstack):
        self.editorstacks.append(editorstack)
        if self.isAncestorOf(editorstack):
            # editorstack is a child of the Editor plugin
            editorstack.set_fullpath_sorting_enabled(True)
            editorstack.set_closable(len(self.editorstacks) > 1)
            editorstack.set_outlineexplorer(self.outlineexplorer)
            editorstack.set_find_widget(self.find_widget)
            oe_btn = create_toolbutton(self)
            oe_btn.setDefaultAction(self.outlineexplorer.visibility_action)
            editorstack.add_corner_widgets_to_tabbar([5, oe_btn])

        editorstack.set_io_actions(*self.io_actions)
        font = Qt.QFont("Monospace")
        font.setPointSize(10)
        editorstack.set_default_font(font, color_scheme='Spyder')
        editorstack.close_file.connect(self.close_file_in_all_editorstacks)
        editorstack.create_new_window.connect(self.create_new_window)
        editorstack.plugin_load.connect(self.load)
Beispiel #38
0
    def register_editorstack(self, editorstack):
        self.editorstacks.append(editorstack)
        if self.isAncestorOf(editorstack):
            # editorstack is a child of the Editor plugin
            editorstack.set_fullpath_sorting_enabled(True)
            editorstack.set_closable(len(self.editorstacks) > 1)
            editorstack.set_outlineexplorer(self.outlineexplorer)
            editorstack.set_find_widget(self.find_widget)
            oe_btn = create_toolbutton(self)
            oe_btn.setDefaultAction(self.outlineexplorer.visibility_action)
            editorstack.add_corner_widgets_to_tabbar([5, oe_btn])

        editorstack.set_io_actions(*self.io_actions)
        font = Qt.QFont("Monospace")
        font.setPointSize(10)
        editorstack.set_default_font(font, color_scheme='Spyder')
        editorstack.close_file.connect(self.close_file_in_all_editorstacks)
        editorstack.create_new_window.connect(self.create_new_window)
        editorstack.plugin_load.connect(self.load)
Beispiel #39
0
    def __init__(self, parent):
        self.tabwidget = None
        self.menu_actions = None
        self.dockviewer = None
        self.wrap_action = None

        self.editors = []
        self.filenames = []
        self.icons = []

        SpyderPluginWidget.__init__(self, parent)

        # Initialize plugin
        self.initialize_plugin()

        self.set_default_color_scheme()

        layout = QVBoxLayout()
        self.tabwidget = Tabs(self, self.menu_actions)
        self.connect(self.tabwidget, SIGNAL('currentChanged(int)'),
                     self.refresh_plugin)
        self.connect(self.tabwidget, SIGNAL('move_data(int,int)'),
                     self.move_tab)
        layout.addWidget(self.tabwidget)

        # Menu as corner widget
        options_button = create_toolbutton(self,
                                           text=_("Options"),
                                           icon=get_icon('tooloptions.png'))
        options_button.setPopupMode(QToolButton.InstantPopup)
        menu = QMenu(self)
        add_actions(menu, self.menu_actions)
        options_button.setMenu(menu)
        self.tabwidget.setCornerWidget(options_button)

        # Find/replace widget
        self.find_widget = FindReplace(self)
        self.find_widget.hide()
        self.register_widget_shortcuts("Editor", self.find_widget)

        layout.addWidget(self.find_widget)

        self.setLayout(layout)
Beispiel #40
0
    def __init__(self, parent):
        self.tabwidget = None
        self.menu_actions = None
        self.dockviewer = None
        self.wrap_action = None
        
        self.editors = []
        self.filenames = []
        self.icons = []
        if PYQT5:        
            SpyderPluginWidget.__init__(self, parent, main = parent)
        else:
            SpyderPluginWidget.__init__(self, parent)

        # Initialize plugin
        self.initialize_plugin()
        
        self.set_default_color_scheme()
        
        layout = QVBoxLayout()
        self.tabwidget = Tabs(self, self.menu_actions)
        self.tabwidget.currentChanged.connect(self.refresh_plugin)
        self.tabwidget.move_data.connect(self.move_tab)
        layout.addWidget(self.tabwidget)

        # Menu as corner widget
        options_button = create_toolbutton(self, text=_('Options'),
                                           icon=ima.icon('tooloptions'))
        options_button.setPopupMode(QToolButton.InstantPopup)
        menu = QMenu(self)
        add_actions(menu, self.menu_actions)
        options_button.setMenu(menu)
        self.tabwidget.setCornerWidget(options_button)
        
        # Find/replace widget
        self.find_widget = FindReplace(self)
        self.find_widget.hide()
        self.register_widget_shortcuts("Editor", self.find_widget)
        
        layout.addWidget(self.find_widget)
        
        self.setLayout(layout)
Beispiel #41
0
    def __init__(self, parent, canvas, num):        
        self.canvas = canvas
        self.num = num
        PluginWidget.__init__(self, parent)

        # Close button
        self.close_button = create_toolbutton(self, triggered=self.close,
                                      icon=get_icon("fileclose.png"),
                                      tip=self.tr("Close figure %1").arg(num))
        
        # Top horizontal layout
        self.h_layout = QHBoxLayout()
        self.statusbar = self.set_statusbar()        
        self.h_layout.addWidget(self.statusbar)
        self.h_layout.addWidget(self.close_button)
        
        # Main vertical layout
        self.v_layout = QVBoxLayout()
        self.v_layout.addLayout(self.h_layout)
        self.v_layout.addWidget(self.canvas)
        self.setLayout(self.v_layout)
Beispiel #42
0
    def __init__(self, parent):
        ReadOnlyEditor.__init__(self, parent)
        
        self.shell = 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 = DocComboBox(self)
        layout_edit.addWidget(self.combo)
        self.combo.setMaxCount(CONF.get(self.ID, 'max_history_entries'))
        dvhistory = self.load_dvhistory()
        self.combo.addItems( dvhistory )
        
        # Doc/source checkbox
        self.help_or_doc = QCheckBox(self.tr("Show source"))
        self.connect(self.help_or_doc, SIGNAL("stateChanged(int)"),
                     self.toggle_help)
        layout_edit.addWidget(self.help_or_doc)
        self.docstring = None
        self.autosource = False
        self.toggle_help(Qt.Unchecked)
        
        # Lock checkbox
        self.locked_button = create_toolbutton(self,
                                               triggered=self.toggle_locked)
        layout_edit.addWidget(self.locked_button)
        self._update_lock_icon()

        # Main layout
        layout = QVBoxLayout()
        layout.addLayout(layout_edit)
        layout.addWidget(self.editor)
        layout.addWidget(self.find_widget)
        self.setLayout(layout)
Beispiel #43
0
    def __init__(self, parent):
        ReadOnlyEditor.__init__(self, parent)

        self.shell = 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 = DocComboBox(self)
        layout_edit.addWidget(self.combo)
        self.combo.setMaxCount(CONF.get(self.ID, 'max_history_entries'))
        dvhistory = self.load_dvhistory()
        self.combo.addItems(dvhistory)

        # Doc/source checkbox
        self.help_or_doc = QCheckBox(self.tr("Show source"))
        self.connect(self.help_or_doc, SIGNAL("stateChanged(int)"),
                     self.toggle_help)
        layout_edit.addWidget(self.help_or_doc)
        self.docstring = None
        self.autosource = False
        self.toggle_help(Qt.Unchecked)

        # Lock checkbox
        self.locked_button = create_toolbutton(self,
                                               triggered=self.toggle_locked)
        layout_edit.addWidget(self.locked_button)
        self._update_lock_icon()

        # Main layout
        layout = QVBoxLayout()
        layout.addLayout(layout_edit)
        layout.addWidget(self.editor)
        layout.addWidget(self.find_widget)
        self.setLayout(layout)
Beispiel #44
0
 def __init__(self, parent, actions=None):
     BaseTabs.__init__(self, parent, actions)
     tab_bar = TabBar(self, parent)
     self.connect(tab_bar, SIGNAL('move_tab(int,int)'), self.move_tab)
     self.connect(tab_bar, SIGNAL('move_tab(long,int,int)'),
                  self.move_tab_from_another_tabwidget)
     self.setTabBar(tab_bar)
     self.index_history = []
     self.connect(self, SIGNAL('currentChanged(int)'),
                  self.__current_changed)
     tabsc = QShortcut(QKeySequence("Ctrl+Tab"), parent, self.tab_navigate)
     tabsc.setContext(Qt.WidgetWithChildrenShortcut)
     # Browsing tabs button
     browse_button = create_toolbutton(self,
                                       icon=get_icon("browse_tab.png"),
                                       tip=translate("Tabs", "Browse tabs"))
     self.browse_tabs_menu = QMenu(self)
     browse_button.setMenu(self.browse_tabs_menu)
     browse_button.setPopupMode(browse_button.InstantPopup)
     self.connect(self.browse_tabs_menu, SIGNAL("aboutToShow()"),
                  self.update_browse_tabs_menu)
     self.setCornerWidget(browse_button)
Beispiel #45
0
    def __init__(self, parent, commands=None):
        self.commands = commands
        self.tabwidget = None
        self.menu_actions = None
        self.docviewer = None
        self.historylog = None

        self.shells = []
        self.filenames = []
        self.icons = []

        PluginWidget.__init__(self, parent)

        layout = QVBoxLayout()
        self.tabwidget = Tabs(self, self.menu_actions)
        self.connect(self.tabwidget, SIGNAL('currentChanged(int)'),
                     self.refresh)
        self.connect(self.tabwidget, SIGNAL("close_tab(int)"),
                     self.tabwidget.removeTab)
        self.connect(self.tabwidget, SIGNAL('move_data(int,int)'),
                     self.move_tab)
        self.close_button = create_toolbutton(
            self.tabwidget,
            icon=get_icon("fileclose.png"),
            triggered=self.close_console,
            tip=self.tr("Close current console"))
        self.tabwidget.setCornerWidget(self.close_button)
        layout.addWidget(self.tabwidget)

        # Find/replace widget
        self.find_widget = FindReplace(self)
        self.find_widget.hide()
        layout.addWidget(self.find_widget)

        self.setLayout(layout)

        # Accepting drops
        self.setAcceptDrops(True)
 def __init__(self, parent, commands=None):
     self.commands = commands
     self.tabwidget = None
     self.menu_actions = None
     self.docviewer = None
     self.historylog = None
     
     self.shells = []
     self.filenames = []
     self.icons = []
     
     PluginWidget.__init__(self, parent)
     
     layout = QVBoxLayout()
     self.tabwidget = Tabs(self, self.menu_actions)
     self.connect(self.tabwidget, SIGNAL('currentChanged(int)'),
                  self.refresh)
     self.connect(self.tabwidget, SIGNAL("close_tab(int)"),
                  self.tabwidget.removeTab)
     self.connect(self.tabwidget, SIGNAL('move_data(int,int)'),
                  self.move_tab)
     self.close_button = create_toolbutton(self.tabwidget,
                                       icon=get_icon("fileclose.png"),
                                       triggered=self.close_console,
                                       tip=self.tr("Close current console"))
     self.tabwidget.setCornerWidget(self.close_button)
     layout.addWidget(self.tabwidget)
     
     # Find/replace widget
     self.find_widget = FindReplace(self)
     self.find_widget.hide()
     layout.addWidget(self.find_widget)
     
     self.setLayout(layout)
         
     # Accepting drops
     self.setAcceptDrops(True)
Beispiel #47
0
    def __init__(self, parent):
        self.tabwidget = None
        self.menu_actions = None
        self.dockviewer = None

        self.editors = []
        self.filenames = []
        self.icons = []

        PluginWidget.__init__(self, parent)

        layout = QVBoxLayout()
        self.tabwidget = Tabs(self, self.menu_actions)
        self.connect(self.tabwidget, SIGNAL('currentChanged(int)'),
                     self.refresh)
        self.connect(self.tabwidget, SIGNAL("close_tab(int)"),
                     self.tabwidget.removeTab)
        self.connect(self.tabwidget, SIGNAL('move_data(int,int)'),
                     self.move_tab)
        layout.addWidget(self.tabwidget)

        # Menu as corner widget
        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, self.menu_actions)
        options_button.setMenu(menu)
        self.tabwidget.setCornerWidget(options_button)

        # Find/replace widget
        self.find_widget = FindReplace(self)
        self.find_widget.hide()
        layout.addWidget(self.find_widget)

        self.setLayout(layout)
Beispiel #48
0
    def __init__(self, parent, enable_replace=False):
        QWidget.__init__(self, parent)
        self.enable_replace = enable_replace
        self.editor = None
        self.is_code_editor = None
        
        glayout = QGridLayout()
        glayout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(glayout)
        
        self.close_button = create_toolbutton(self, triggered=self.hide,
                                      icon=ima.icon('DialogCloseButton'))
        glayout.addWidget(self.close_button, 0, 0)
        
        # Find layout
        self.search_text = PatternComboBox(self, tip=_("Search string"),
                                           adjust_to_minimum=False)
        self.search_text.valid.connect(
                     lambda state:
                     self.find(changed=False, forward=True, rehighlight=False))
        self.search_text.lineEdit().textEdited.connect(
                                                     self.text_has_been_edited)
        
        self.previous_button = create_toolbutton(self,
                                             triggered=self.find_previous,
                                             icon=ima.icon('ArrowUp'))
        self.next_button = create_toolbutton(self,
                                             triggered=self.find_next,
                                             icon=ima.icon('ArrowDown'))
        self.next_button.clicked.connect(self.update_search_combo)
        self.previous_button.clicked.connect(self.update_search_combo)

        self.re_button = create_toolbutton(self, icon=ima.icon('advanced'),
                                           tip=_("Regular expression"))
        self.re_button.setCheckable(True)
        self.re_button.toggled.connect(lambda state: self.find())
        
        self.case_button = create_toolbutton(self,
                                             icon=get_icon("upper_lower.png"),
                                             tip=_("Case Sensitive"))
        self.case_button.setCheckable(True)
        self.case_button.toggled.connect(lambda state: self.find())
                     
        self.words_button = create_toolbutton(self,
                                              icon=get_icon("whole_words.png"),
                                              tip=_("Whole words"))
        self.words_button.setCheckable(True)
        self.words_button.toggled.connect(lambda state: self.find())
                     
        self.highlight_button = create_toolbutton(self,
                                              icon=get_icon("highlight.png"),
                                              tip=_("Highlight matches"))
        self.highlight_button.setCheckable(True)
        self.highlight_button.toggled.connect(self.toggle_highlighting)

        hlayout = QHBoxLayout()
        self.widgets = [self.close_button, self.search_text,
                        self.previous_button, self.next_button,
                        self.re_button, self.case_button, self.words_button,
                        self.highlight_button]
        for widget in self.widgets[1:]:
            hlayout.addWidget(widget)
        glayout.addLayout(hlayout, 0, 1)

        # Replace layout
        replace_with = QLabel(_("Replace with:"))
        self.replace_text = PatternComboBox(self, adjust_to_minimum=False,
                                            tip=_('Replace string'))
        
        self.replace_button = create_toolbutton(self,
                                     text=_('Replace/find'),
                                     icon=ima.icon('DialogApplyButton'),
                                     triggered=self.replace_find,
                                     text_beside_icon=True)
        self.replace_button.clicked.connect(self.update_replace_combo)
        self.replace_button.clicked.connect(self.update_search_combo)
        
        self.all_check = QCheckBox(_("Replace all"))
        
        self.replace_layout = QHBoxLayout()
        widgets = [replace_with, self.replace_text, self.replace_button,
                   self.all_check]
        for widget in widgets:
            self.replace_layout.addWidget(widget)
        glayout.addLayout(self.replace_layout, 1, 1)
        self.widgets.extend(widgets)
        self.replace_widgets = widgets
        self.hide_replace()
        
        self.search_text.setTabOrder(self.search_text, self.replace_text)
        
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        
        self.shortcuts = self.create_shortcuts(parent)
        
        self.highlight_timer = QTimer(self)
        self.highlight_timer.setSingleShot(True)
        self.highlight_timer.setInterval(1000)
        self.highlight_timer.timeout.connect(self.highlight_matches)
Beispiel #49
0
    def setup_toolbar(self, exclude_private, exclude_uppercase,
                      exclude_capitalized, exclude_unsupported, autorefresh):
        """Setup toolbar"""
        self.setup_in_progress = True                          
                          
        toolbar = []

        refresh_button = create_toolbutton(self, text=_('Refresh'),
                                           icon=ima.icon('reload'),
                                           triggered=self.refresh_table)
        self.auto_refresh_button = create_toolbutton(self,
                                           text=_('Refresh periodically'),
                                           icon=ima.icon('auto_reload'),
                                           toggled=self.toggle_auto_refresh)
        self.auto_refresh_button.setChecked(autorefresh)
        load_button = create_toolbutton(self, text=_('Import data'),
                                        icon=ima.icon('fileimport'),
                                        triggered=self.import_data)
        self.save_button = create_toolbutton(self, text=_("Save data"),
                            icon=ima.icon('filesave'),
                            triggered=lambda: self.save_data(self.filename))
        self.save_button.setEnabled(False)
        save_as_button = create_toolbutton(self,
                                           text=_("Save data as..."),
                                           icon=ima.icon('filesaveas'),
                                           triggered=self.save_data)
        toolbar += [refresh_button, self.auto_refresh_button, load_button,
                    self.save_button, save_as_button]
        
        self.exclude_private_action = create_action(self,
                _("Exclude private references"),
                tip=_("Exclude references which name starts"
                            " with an underscore"),
                toggled=lambda state:
                self.sig_option_changed.emit('exclude_private', state))
        self.exclude_private_action.setChecked(exclude_private)
        
        self.exclude_uppercase_action = create_action(self,
                _("Exclude all-uppercase references"),
                tip=_("Exclude references which name is uppercase"),
                toggled=lambda state:
                self.sig_option_changed.emit('exclude_uppercase', state))
        self.exclude_uppercase_action.setChecked(exclude_uppercase)
        
        self.exclude_capitalized_action = create_action(self,
                _("Exclude capitalized references"),
                tip=_("Exclude references which name starts with an "
                      "uppercase character"),
                toggled=lambda state:
                self.sig_option_changed.emit('exclude_capitalized', state))
        self.exclude_capitalized_action.setChecked(exclude_capitalized)
        
        self.exclude_unsupported_action = create_action(self,
                _("Exclude unsupported data types"),
                tip=_("Exclude references to unsupported data types"
                            " (i.e. which won't be handled/saved correctly)"),
                toggled=lambda state:
                self.sig_option_changed.emit('exclude_unsupported', state))
        self.exclude_unsupported_action.setChecked(exclude_unsupported)
        
        options_button = create_toolbutton(self, text=_('Options'),
                                           icon=ima.icon('tooloptions'))
        toolbar.append(options_button)
        options_button.setPopupMode(QToolButton.InstantPopup)
        menu = QMenu(self)
        editor = self.editor
        actions = [self.exclude_private_action, self.exclude_uppercase_action,
                   self.exclude_capitalized_action,
                   self.exclude_unsupported_action, None,
                   editor.truncate_action]
        if is_module_installed('numpy'):
            actions.append(editor.minmax_action)
        add_actions(menu, actions)
        options_button.setMenu(menu)
        
        self.setup_in_progress = False
        
        return toolbar
Beispiel #50
0
    def __init__(self, parent, enable_replace=False):
        QWidget.__init__(self, parent)
        self.enable_replace = enable_replace
        self.editor = None
        self.is_code_editor = None

        glayout = QGridLayout()
        glayout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(glayout)

        self.close_button = create_toolbutton(
            self, triggered=self.hide, icon=ima.icon('DialogCloseButton'))
        glayout.addWidget(self.close_button, 0, 0)

        # Find layout
        self.search_text = PatternComboBox(self,
                                           tip=_("Search string"),
                                           adjust_to_minimum=False)
        self.search_text.valid.connect(lambda state: self.find(
            changed=False, forward=True, rehighlight=False))
        self.search_text.lineEdit().textEdited.connect(
            self.text_has_been_edited)

        self.previous_button = create_toolbutton(self,
                                                 triggered=self.find_previous,
                                                 icon=ima.icon('ArrowUp'))
        self.next_button = create_toolbutton(self,
                                             triggered=self.find_next,
                                             icon=ima.icon('ArrowDown'))
        self.next_button.clicked.connect(self.update_search_combo)
        self.previous_button.clicked.connect(self.update_search_combo)

        self.re_button = create_toolbutton(self,
                                           icon=ima.icon('advanced'),
                                           tip=_("Regular expression"))
        self.re_button.setCheckable(True)
        self.re_button.toggled.connect(lambda state: self.find())

        self.case_button = create_toolbutton(self,
                                             icon=get_icon("upper_lower.png"),
                                             tip=_("Case Sensitive"))
        self.case_button.setCheckable(True)
        self.case_button.toggled.connect(lambda state: self.find())

        self.words_button = create_toolbutton(self,
                                              icon=get_icon("whole_words.png"),
                                              tip=_("Whole words"))
        self.words_button.setCheckable(True)
        self.words_button.toggled.connect(lambda state: self.find())

        self.highlight_button = create_toolbutton(
            self, icon=get_icon("highlight.png"), tip=_("Highlight matches"))
        self.highlight_button.setCheckable(True)
        self.highlight_button.toggled.connect(self.toggle_highlighting)

        hlayout = QHBoxLayout()
        self.widgets = [
            self.close_button, self.search_text, self.previous_button,
            self.next_button, self.re_button, self.case_button,
            self.words_button, self.highlight_button
        ]
        for widget in self.widgets[1:]:
            hlayout.addWidget(widget)
        glayout.addLayout(hlayout, 0, 1)

        # Replace layout
        replace_with = QLabel(_("Replace with:"))
        self.replace_text = PatternComboBox(self,
                                            adjust_to_minimum=False,
                                            tip=_('Replace string'))

        self.replace_button = create_toolbutton(
            self,
            text=_('Replace/find'),
            icon=ima.icon('DialogApplyButton'),
            triggered=self.replace_find,
            text_beside_icon=True)
        self.replace_button.clicked.connect(self.update_replace_combo)
        self.replace_button.clicked.connect(self.update_search_combo)

        self.all_check = QCheckBox(_("Replace all"))

        self.replace_layout = QHBoxLayout()
        widgets = [
            replace_with, self.replace_text, self.replace_button,
            self.all_check
        ]
        for widget in widgets:
            self.replace_layout.addWidget(widget)
        glayout.addLayout(self.replace_layout, 1, 1)
        self.widgets.extend(widgets)
        self.replace_widgets = widgets
        self.hide_replace()

        self.search_text.setTabOrder(self.search_text, self.replace_text)

        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)

        self.shortcuts = self.create_shortcuts(parent)

        self.highlight_timer = QTimer(self)
        self.highlight_timer.setSingleShot(True)
        self.highlight_timer.setInterval(1000)
        self.highlight_timer.timeout.connect(self.highlight_matches)
Beispiel #51
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.home_url = None

        self.webview = WebView(self)
        self.webview.loadFinished.connect(self.load_finished)
        self.webview.titleChanged.connect(self.setWindowTitle)
        self.webview.urlChanged.connect(self.url_changed)

        home_button = create_toolbutton(self,
                                        icon=ima.icon('home'),
                                        tip=_("Home"),
                                        triggered=self.go_home)

        zoom_out_button = action2button(self.webview.zoom_out_action)
        zoom_in_button = action2button(self.webview.zoom_in_action)

        pageact2btn = lambda prop: action2button(self.webview.pageAction(prop),
                                                 parent=self.webview)
        refresh_button = pageact2btn(QWebPage.Reload)
        stop_button = pageact2btn(QWebPage.Stop)
        previous_button = pageact2btn(QWebPage.Back)
        next_button = pageact2btn(QWebPage.Forward)

        stop_button.setEnabled(False)
        self.webview.loadStarted.connect(lambda: stop_button.setEnabled(True))
        self.webview.loadFinished.connect(
            lambda: stop_button.setEnabled(False))

        progressbar = QProgressBar(self)
        progressbar.setTextVisible(False)
        progressbar.hide()
        self.webview.loadStarted.connect(progressbar.show)
        self.webview.loadProgress.connect(progressbar.setValue)
        self.webview.loadFinished.connect(lambda _state: progressbar.hide())

        label = QLabel(self.get_label())

        self.url_combo = UrlComboBox(self)
        self.url_combo.valid.connect(self.url_combo_activated)
        self.webview.iconChanged.connect(self.icon_changed)

        self.find_widget = FindReplace(self)
        self.find_widget.set_editor(self.webview)
        self.find_widget.hide()

        find_button = create_toolbutton(self,
                                        icon=ima.icon('find'),
                                        tip=_("Find text"),
                                        toggled=self.toggle_find_widget)
        self.find_widget.visibility_changed.connect(find_button.setChecked)

        hlayout = QHBoxLayout()
        for widget in (previous_button, next_button, home_button, find_button,
                       label, self.url_combo, zoom_out_button, zoom_in_button,
                       refresh_button, progressbar, stop_button):
            hlayout.addWidget(widget)

        layout = QVBoxLayout()
        layout.addLayout(hlayout)
        layout.addWidget(self.webview)
        layout.addWidget(self.find_widget)
        self.setLayout(layout)
Beispiel #52
0
    def __init__(self, parent, max_entries=100):
        QWidget.__init__(self, parent)
        
        self.setWindowTitle("Pylint")
        
        self.output = None
        self.error_output = None
        
        self.max_entries = max_entries
        self.rdata = []
        if osp.isfile(self.DATAPATH):
            try:
                data = pickle.loads(open(self.DATAPATH, 'rb').read())
                if data[0] == self.VERSION:
                    self.rdata = data[1:]
            except (EOFError, ImportError):
                pass

        self.filecombo = PythonModulesComboBox(self)
        if self.rdata:
            self.remove_obsolete_items()
            self.filecombo.addItems(self.get_filenames())
        
        self.start_button = create_toolbutton(self, icon=get_icon('run.png'),
                                    text=_("Analyze"),
                                    tip=_("Run analysis"),
                                    triggered=self.start, text_beside_icon=True)
        self.stop_button = create_toolbutton(self,
                                             icon=get_icon('stop.png'),
                                             text=_("Stop"),
                                             tip=_("Stop current analysis"),
                                             text_beside_icon=True)
        self.connect(self.filecombo, SIGNAL('valid(bool)'),
                     self.start_button.setEnabled)
        self.connect(self.filecombo, SIGNAL('valid(bool)'), self.show_data)

        browse_button = create_toolbutton(self, icon=get_icon('fileopen.png'),
                               tip=_('Select Python file'),
                               triggered=self.select_file)

        self.ratelabel = QLabel()
        self.datelabel = QLabel()
        self.log_button = create_toolbutton(self, icon=get_icon('log.png'),
                                    text=_("Output"),
                                    text_beside_icon=True,
                                    tip=_("Complete output"),
                                    triggered=self.show_log)
        self.treewidget = ResultsTree(self)
        
        hlayout1 = QHBoxLayout()
        hlayout1.addWidget(self.filecombo)
        hlayout1.addWidget(browse_button)
        hlayout1.addWidget(self.start_button)
        hlayout1.addWidget(self.stop_button)

        hlayout2 = QHBoxLayout()
        hlayout2.addWidget(self.ratelabel)
        hlayout2.addStretch()
        hlayout2.addWidget(self.datelabel)
        hlayout2.addStretch()
        hlayout2.addWidget(self.log_button)
        
        layout = QVBoxLayout()
        layout.addLayout(hlayout1)
        layout.addLayout(hlayout2)
        layout.addWidget(self.treewidget)
        self.setLayout(layout)
        
        self.process = None
        self.set_running_state(False)
        
        if PYLINT_PATH is None:
            for widget in (self.treewidget, self.filecombo,
                           self.start_button, self.stop_button):
                widget.setDisabled(True)
            if os.name == 'nt' \
               and programs.is_module_installed("pylint"):
                # Pylint is installed but pylint script is not in PATH
                # (AFAIK, could happen only on Windows)
                text = _('Pylint script was not found. Please add "%s" to PATH.')
                text = to_text_string(text) % osp.join(sys.prefix, "Scripts")
            else:
                text = _('Please install <b>pylint</b>:')
                url = 'http://www.logilab.fr'
                text += ' <a href=%s>%s</a>' % (url, url)
            self.ratelabel.setText(text)
        else:
            self.show_data()
Beispiel #53
0
    def setup_toolbar(self, layout):
        toolbar = []

        explorer_label = QLabel(
            self.tr("<span style=\'color: #444444\'>"
                    "<b>Global variables explorer</b>"
                    "</span>"))
        toolbar.append(explorer_label)

        hide_button = create_toolbutton(self,
                                        text=self.tr("Hide"),
                                        icon=get_icon('hide.png'),
                                        triggered=self.collapse)
        toolbar.append(hide_button)

        refresh_button = create_toolbutton(self,
                                           text=self.tr("Refresh"),
                                           icon=get_icon('reload.png'),
                                           triggered=self.refresh_table)
        toolbar.append(refresh_button)

        exclude_private_action = create_action(
            self,
            self.tr("Exclude private references"),
            tip=self.tr("Exclude references which name starts"
                        " with an underscore"),
            toggled=lambda state: self.emit(SIGNAL('option_changed'),
                                            'exclude_private', state))
        exclude_private_action.setChecked(CONF.get(self.ID, 'exclude_private'))

        exclude_upper_action = create_action(
            self,
            self.tr("Exclude capitalized references"),
            tip=self.tr("Exclude references which name starts with an "
                        "upper-case character"),
            toggled=lambda state: self.emit(SIGNAL('option_changed'),
                                            'exclude_upper', state))
        exclude_upper_action.setChecked(CONF.get(self.ID, 'exclude_upper'))

        exclude_unsupported_action = create_action(
            self,
            self.tr("Exclude unsupported data types"),
            tip=self.tr("Exclude references to unsupported data types"
                        " (i.e. which won't be handled/saved correctly)"),
            toggled=lambda state: self.emit(SIGNAL('option_changed'),
                                            'exclude_unsupported', state))
        exclude_unsupported_action.setChecked(
            CONF.get(self.ID, 'exclude_unsupported'))

        options_button = create_toolbutton(self,
                                           text=self.tr("Options"),
                                           icon=get_icon('tooloptions.png'))
        toolbar.append(options_button)
        options_button.setPopupMode(QToolButton.InstantPopup)
        menu = QMenu(self)
        editor = self.editor
        actions = [
            exclude_private_action, exclude_upper_action,
            exclude_unsupported_action, None, editor.truncate_action,
            editor.inplace_action, editor.collvalue_action
        ]
        try:
            imp.find_module('numpy')
            actions.append(editor.minmax_action)
        except ImportError:
            pass
        add_actions(menu, actions)
        options_button.setMenu(menu)

        layout.setAlignment(Qt.AlignLeft)
        for widget in toolbar:
            layout.addWidget(widget)
        layout.insertStretch(1, 1)
Beispiel #54
0
    def setup(self,
              check_all=None,
              exclude_private=None,
              exclude_uppercase=None,
              exclude_capitalized=None,
              exclude_unsupported=None,
              excluded_names=None,
              truncate=None,
              minmax=None,
              remote_editing=None,
              autorefresh=None):
        """Setup the namespace browser"""
        assert self.shellwidget is not None

        self.check_all = check_all
        self.exclude_private = exclude_private
        self.exclude_uppercase = exclude_uppercase
        self.exclude_capitalized = exclude_capitalized
        self.exclude_unsupported = exclude_unsupported
        self.excluded_names = excluded_names
        self.truncate = truncate
        self.minmax = minmax
        self.remote_editing = remote_editing
        self.autorefresh = autorefresh

        if self.editor is not None:
            self.editor.setup_menu(truncate, minmax)
            self.exclude_private_action.setChecked(exclude_private)
            self.exclude_uppercase_action.setChecked(exclude_uppercase)
            self.exclude_capitalized_action.setChecked(exclude_capitalized)
            self.exclude_unsupported_action.setChecked(exclude_unsupported)
            # Don't turn autorefresh on for IPython kernels
            # See Issue 1450
            if not self.is_ipykernel:
                self.auto_refresh_button.setChecked(autorefresh)
            self.refresh_table()
            return

        # Dict editor:
        if self.is_internal_shell:
            self.editor = CollectionsEditorTableView(self,
                                                     None,
                                                     truncate=truncate,
                                                     minmax=minmax)
        else:
            self.editor = RemoteCollectionsEditorTableView(
                self,
                None,
                truncate=truncate,
                minmax=minmax,
                remote_editing=remote_editing,
                get_value_func=self.get_value,
                set_value_func=self.set_value,
                new_value_func=self.set_value,
                remove_values_func=self.remove_values,
                copy_value_func=self.copy_value,
                is_list_func=self.is_list,
                get_len_func=self.get_len,
                is_array_func=self.is_array,
                is_image_func=self.is_image,
                is_dict_func=self.is_dict,
                is_data_frame_func=self.is_data_frame,
                is_series_func=self.is_series,
                get_array_shape_func=self.get_array_shape,
                get_array_ndim_func=self.get_array_ndim,
                oedit_func=self.oedit,
                plot_func=self.plot,
                imshow_func=self.imshow,
                show_image_func=self.show_image)
        self.editor.sig_option_changed.connect(self.sig_option_changed.emit)
        self.editor.sig_files_dropped.connect(self.import_data)

        # Setup layout
        layout = QVBoxLayout()
        blayout = QHBoxLayout()
        toolbar = self.setup_toolbar(exclude_private, exclude_uppercase,
                                     exclude_capitalized, exclude_unsupported,
                                     autorefresh)
        for widget in toolbar:
            blayout.addWidget(widget)

        # Options menu
        options_button = create_toolbutton(self,
                                           text=_('Options'),
                                           icon=ima.icon('tooloptions'))
        options_button.setPopupMode(QToolButton.InstantPopup)
        menu = QMenu(self)
        editor = self.editor
        actions = [
            self.exclude_private_action, self.exclude_uppercase_action,
            self.exclude_capitalized_action, self.exclude_unsupported_action,
            None, editor.truncate_action
        ]
        if is_module_installed('numpy'):
            actions.append(editor.minmax_action)
        add_actions(menu, actions)
        options_button.setMenu(menu)

        blayout.addStretch()
        blayout.addWidget(options_button)
        layout.addLayout(blayout)
        layout.addWidget(self.editor)
        self.setLayout(layout)
        layout.setContentsMargins(0, 0, 0, 0)

        self.sig_option_changed.connect(self.option_changed)
Beispiel #55
0
    def setup_toolbar(self, exclude_private, exclude_uppercase,
                      exclude_capitalized, exclude_unsupported, autorefresh):
        """Setup toolbar"""
        self.setup_in_progress = True

        toolbar = []

        refresh_button = create_toolbutton(self,
                                           text=_('Refresh'),
                                           icon=ima.icon('reload'),
                                           triggered=self.refresh_table)
        self.auto_refresh_button = create_toolbutton(
            self,
            text=_('Refresh periodically'),
            icon=ima.icon('auto_reload'),
            toggled=self.toggle_auto_refresh)
        self.auto_refresh_button.setChecked(autorefresh)
        load_button = create_toolbutton(self,
                                        text=_('Import data'),
                                        icon=ima.icon('fileimport'),
                                        triggered=lambda: self.import_data())
        self.save_button = create_toolbutton(
            self,
            text=_("Save data"),
            icon=ima.icon('filesave'),
            triggered=lambda: self.save_data(self.filename))
        self.save_button.setEnabled(False)
        save_as_button = create_toolbutton(self,
                                           text=_("Save data as..."),
                                           icon=ima.icon('filesaveas'),
                                           triggered=self.save_data)
        toolbar += [
            refresh_button, self.auto_refresh_button, load_button,
            self.save_button, save_as_button
        ]

        self.exclude_private_action = create_action(
            self,
            _("Exclude private references"),
            tip=_("Exclude references which name starts"
                  " with an underscore"),
            toggled=lambda state: self.sig_option_changed.emit(
                'exclude_private', state))
        self.exclude_private_action.setChecked(exclude_private)

        self.exclude_uppercase_action = create_action(
            self,
            _("Exclude all-uppercase references"),
            tip=_("Exclude references which name is uppercase"),
            toggled=lambda state: self.sig_option_changed.emit(
                'exclude_uppercase', state))
        self.exclude_uppercase_action.setChecked(exclude_uppercase)

        self.exclude_capitalized_action = create_action(
            self,
            _("Exclude capitalized references"),
            tip=_("Exclude references which name starts with an "
                  "uppercase character"),
            toggled=lambda state: self.sig_option_changed.emit(
                'exclude_capitalized', state))
        self.exclude_capitalized_action.setChecked(exclude_capitalized)

        self.exclude_unsupported_action = create_action(
            self,
            _("Exclude unsupported data types"),
            tip=_("Exclude references to unsupported data types"
                  " (i.e. which won't be handled/saved correctly)"),
            toggled=lambda state: self.sig_option_changed.emit(
                'exclude_unsupported', state))
        self.exclude_unsupported_action.setChecked(exclude_unsupported)

        self.setup_in_progress = False

        return toolbar
Beispiel #56
0
    def __init__(self, parent, max_entries=100):
        QWidget.__init__(self, parent)

        self.setWindowTitle("Profiler")

        self.output = None
        self.error_output = None

        self._last_wdir = None
        self._last_args = None
        self._last_pythonpath = None

        self.filecombo = PythonModulesComboBox(self)

        self.start_button = create_toolbutton(self,
                                              icon=get_icon('run.png'),
                                              text=_("Profile"),
                                              tip=_("Run profiler"),
                                              triggered=lambda: self.start(),
                                              text_beside_icon=True)
        self.stop_button = create_toolbutton(self,
                                             icon=get_icon('stop.png'),
                                             text=_("Stop"),
                                             tip=_("Stop current profiling"),
                                             text_beside_icon=True)
        self.filecombo.valid.connect(self.start_button.setEnabled)
        #self.connect(self.filecombo, SIGNAL('valid(bool)'), self.show_data)
        # FIXME: The combobox emits this signal on almost any event
        #        triggering show_data() too early, too often.

        browse_button = create_toolbutton(self,
                                          icon=get_icon('fileopen.png'),
                                          tip=_('Select Python script'),
                                          triggered=self.select_file)

        self.datelabel = QLabel()

        self.log_button = create_toolbutton(self,
                                            icon=get_icon('log.png'),
                                            text=_("Output"),
                                            text_beside_icon=True,
                                            tip=_("Show program's output"),
                                            triggered=self.show_log)

        self.datatree = ProfilerDataTree(self)

        self.collapse_button = create_toolbutton(
            self,
            icon=get_icon('collapse.png'),
            triggered=lambda dD=-1: self.datatree.change_view(dD),
            tip=_('Collapse one level up'))
        self.expand_button = create_toolbutton(
            self,
            icon=get_icon('expand.png'),
            triggered=lambda dD=1: self.datatree.change_view(dD),
            tip=_('Expand one level down'))

        self.save_button = create_toolbutton(self,
                                             text_beside_icon=True,
                                             text=_("Save data"),
                                             icon=get_icon('filesave.png'),
                                             triggered=self.save_data,
                                             tip=_('Save profiling data'))
        self.load_button = create_toolbutton(
            self,
            text_beside_icon=True,
            text=_("Load data"),
            icon=get_icon('fileimport.png'),
            triggered=self.compare,
            tip=_('Load profiling data for comparison'))
        self.clear_button = create_toolbutton(self,
                                              text_beside_icon=True,
                                              text=_("Clear comparison"),
                                              icon=get_icon('eraser.png'),
                                              triggered=self.clear)

        hlayout1 = QHBoxLayout()
        hlayout1.addWidget(self.filecombo)
        hlayout1.addWidget(browse_button)
        hlayout1.addWidget(self.start_button)
        hlayout1.addWidget(self.stop_button)

        hlayout2 = QHBoxLayout()
        hlayout2.addWidget(self.collapse_button)
        hlayout2.addWidget(self.expand_button)
        hlayout2.addStretch()
        hlayout2.addWidget(self.datelabel)
        hlayout2.addStretch()
        hlayout2.addWidget(self.log_button)
        hlayout2.addWidget(self.save_button)
        hlayout2.addWidget(self.load_button)
        hlayout2.addWidget(self.clear_button)

        layout = QVBoxLayout()
        layout.addLayout(hlayout1)
        layout.addLayout(hlayout2)
        layout.addWidget(self.datatree)
        self.setLayout(layout)

        self.process = None
        self.set_running_state(False)
        self.start_button.setEnabled(False)
        self.clear_button.setEnabled(False)

        if not is_profiler_installed():
            # This should happen only on certain GNU/Linux distributions
            # or when this a home-made Python build because the Python
            # profilers are included in the Python standard library
            for widget in (self.datatree, self.filecombo, self.start_button,
                           self.stop_button):
                widget.setDisabled(True)
            url = 'http://docs.python.org/library/profile.html'
            text = '%s <a href=%s>%s</a>' % (_('Please install'), url,
                                             _("the Python profiler modules"))
            self.datelabel.setText(text)
        else:
            pass  # self.show_data()
Beispiel #57
0
    def __init__(self, parent):
        if PYQT5:
            SpyderPluginWidget.__init__(self, parent, main=parent)
        else:
            SpyderPluginWidget.__init__(self, parent)

        self.internal_shell = None

        # Initialize plugin
        self.initialize_plugin()

        self.no_doc_string = _("No further documentation available")

        self._last_console_cb = None
        self._last_editor_cb = None

        self.plain_text = PlainText(self)
        self.rich_text = RichText(self)

        color_scheme = self.get_color_scheme()
        self.set_plain_text_font(self.get_plugin_font(), color_scheme)
        self.plain_text.editor.toggle_wrap_mode(self.get_option('wrap'))

        # Add entries to read-only editor context-menu
        self.wrap_action = create_action(self,
                                         _("Wrap lines"),
                                         toggled=self.toggle_wrap_mode)
        self.wrap_action.setChecked(self.get_option('wrap'))
        self.plain_text.editor.readonly_menu.addSeparator()
        add_actions(self.plain_text.editor.readonly_menu, (self.wrap_action, ))

        self.set_rich_text_font(self.get_plugin_font('rich_text'))

        self.shell = None

        self.external_console = None

        # locked = disable link with Console
        self.locked = False
        self._last_texts = [None, None]
        self._last_editor_doc = None

        # Object name
        layout_edit = QHBoxLayout()
        layout_edit.setContentsMargins(0, 0, 0, 0)
        txt = _("Source")
        if sys.platform == 'darwin':
            source_label = QLabel("  " + txt)
        else:
            source_label = QLabel(txt)
        layout_edit.addWidget(source_label)
        self.source_combo = QComboBox(self)
        self.source_combo.addItems([_("Console"), _("Editor")])
        self.source_combo.currentIndexChanged.connect(self.source_changed)
        if (not programs.is_module_installed('rope')
                and not programs.is_module_installed('jedi', '>=0.8.1')):
            self.source_combo.hide()
            source_label.hide()
        layout_edit.addWidget(self.source_combo)
        layout_edit.addSpacing(10)
        layout_edit.addWidget(QLabel(_("Object")))
        self.combo = ObjectComboBox(self)
        layout_edit.addWidget(self.combo)
        self.object_edit = QLineEdit(self)
        self.object_edit.setReadOnly(True)
        layout_edit.addWidget(self.object_edit)
        self.combo.setMaxCount(self.get_option('max_history_entries'))
        self.combo.addItems(self.load_history())
        self.combo.setItemText(0, '')
        self.combo.valid.connect(lambda valid: self.force_refresh())

        # Plain text docstring option
        self.docstring = True
        self.rich_help = self.get_option('rich_mode', True)
        self.plain_text_action = create_action(self,
                                               _("Plain Text"),
                                               toggled=self.toggle_plain_text)

        # Source code option
        self.show_source_action = create_action(
            self, _("Show Source"), toggled=self.toggle_show_source)

        # Rich text option
        self.rich_text_action = create_action(self,
                                              _("Rich Text"),
                                              toggled=self.toggle_rich_text)

        # Add the help actions to an exclusive QActionGroup
        help_actions = QActionGroup(self)
        help_actions.setExclusive(True)
        help_actions.addAction(self.plain_text_action)
        help_actions.addAction(self.rich_text_action)

        # Automatic import option
        self.auto_import_action = create_action(
            self, _("Automatic import"), toggled=self.toggle_auto_import)
        auto_import_state = self.get_option('automatic_import')
        self.auto_import_action.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=_('Options'),
                                           icon=ima.icon('tooloptions'))
        options_button.setPopupMode(QToolButton.InstantPopup)
        menu = QMenu(self)
        add_actions(menu, [
            self.rich_text_action, self.plain_text_action,
            self.show_source_action, None, self.auto_import_action
        ])
        options_button.setMenu(menu)
        layout_edit.addWidget(options_button)

        if self.rich_help:
            self.switch_to_rich_text()
        else:
            self.switch_to_plain_text()
        self.plain_text_action.setChecked(not self.rich_help)
        self.rich_text_action.setChecked(self.rich_help)
        self.source_changed()

        # Main layout
        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addLayout(layout_edit)
        layout.addWidget(self.plain_text)
        layout.addWidget(self.rich_text)
        self.setLayout(layout)

        # Add worker thread for handling rich text rendering
        self._sphinx_thread = SphinxThread(
            html_text_no_doc=warning(self.no_doc_string))
        self._sphinx_thread.html_ready.connect(
            self._on_sphinx_thread_html_ready)
        self._sphinx_thread.error_msg.connect(self._on_sphinx_thread_error_msg)

        # Handle internal and external links
        view = self.rich_text.webview
        if not WEBENGINE:
            view.page().setLinkDelegationPolicy(
                QWebEnginePage.DelegateAllLinks)
        view.linkClicked.connect(self.handle_link_clicks)

        self._starting_up = True
Beispiel #58
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        
        self.home_url = None
        
        self.webview = WebView(self)
        self.webview.loadFinished.connect(self.load_finished)
        self.webview.titleChanged.connect(self.setWindowTitle)
        self.webview.urlChanged.connect(self.url_changed)
                
        home_button = create_toolbutton(self, icon=ima.icon('home'),
                                        tip=_("Home"),
                                        triggered=self.go_home)
        
        zoom_out_button = action2button(self.webview.zoom_out_action)
        zoom_in_button = action2button(self.webview.zoom_in_action)
        
        pageact2btn = lambda prop: action2button(self.webview.pageAction(prop),
                                                 parent=self.webview)
        refresh_button = pageact2btn(QWebPage.Reload)
        stop_button = pageact2btn(QWebPage.Stop)
        previous_button = pageact2btn(QWebPage.Back)
        next_button = pageact2btn(QWebPage.Forward)
        
        stop_button.setEnabled(False)
        self.webview.loadStarted.connect(lambda: stop_button.setEnabled(True))
        self.webview.loadFinished.connect(lambda: stop_button.setEnabled(False))
        
        progressbar = QProgressBar(self)
        progressbar.setTextVisible(False)
        progressbar.hide()
        self.webview.loadStarted.connect(progressbar.show)
        self.webview.loadProgress.connect(progressbar.setValue)
        self.webview.loadFinished.connect(lambda _state: progressbar.hide())
        
        label = QLabel(self.get_label())
        
        self.url_combo = UrlComboBox(self)
        self.url_combo.valid.connect(self.url_combo_activated)
        self.webview.iconChanged.connect(self.icon_changed)
        
        self.find_widget = FindReplace(self)
        self.find_widget.set_editor(self.webview)
        self.find_widget.hide()

        find_button = create_toolbutton(self, icon=ima.icon('find'),
                                        tip=_("Find text"),
                                        toggled=self.toggle_find_widget)
        self.find_widget.visibility_changed.connect(find_button.setChecked)

        hlayout = QHBoxLayout()
        for widget in (previous_button, next_button, home_button, find_button,
                       label, self.url_combo, zoom_out_button, zoom_in_button,
                       refresh_button, progressbar, stop_button):
            hlayout.addWidget(widget)
        
        layout = QVBoxLayout()
        layout.addLayout(hlayout)
        layout.addWidget(self.webview)
        layout.addWidget(self.find_widget)
        self.setLayout(layout)
Beispiel #59
0
    def __init__(self, parent, max_entries=100):
        QWidget.__init__(self, parent)

        self.output = None
        self.error_output = None

        self.max_entries = max_entries
        self.data = [self.VERSION]
        if osp.isfile(self.DATAPATH):
            try:
                data = cPickle.load(file(self.DATAPATH))
                if data[0] == self.VERSION:
                    self.data = data
            except EOFError:
                pass

        self.filecombo = PythonModulesComboBox(self)
        if self.data:
            self.remove_obsolete_items()
            self.filecombo.addItems(self.get_filenames())

        self.start_button = create_toolbutton(self,
                                              get_icon('run.png'),
                                              translate('Pylint', "Analyze"),
                                              tip=translate(
                                                  'Pylint', "Run analysis"),
                                              triggered=self.start)
        self.stop_button = create_toolbutton(self,
                                             get_icon('terminate.png'),
                                             translate('Pylint', "Stop"),
                                             tip=translate(
                                                 'Pylint',
                                                 "Stop current analysis"))
        self.connect(self.filecombo, SIGNAL('valid(bool)'),
                     self.start_button.setEnabled)
        self.connect(self.filecombo, SIGNAL('valid(bool)'), self.show_data)

        browse_button = create_toolbutton(self,
                                          get_icon('fileopen.png'),
                                          tip=translate(
                                              'Pylint',
                                              'Select Python script'),
                                          triggered=self.select_file)

        self.ratelabel = QLabel()
        self.datelabel = QLabel()
        self.log_button = create_toolbutton(self,
                                            get_icon('log.png'),
                                            translate('Pylint', "Output"),
                                            tip=translate(
                                                'Pylint',
                                                "Complete Pylint output"),
                                            triggered=self.show_log)
        self.treewidget = ResultsTree(self)

        hlayout1 = QHBoxLayout()
        hlayout1.addWidget(self.filecombo)
        hlayout1.addWidget(browse_button)
        hlayout1.addWidget(self.start_button)
        hlayout1.addWidget(self.stop_button)

        hlayout2 = QHBoxLayout()
        hlayout2.addWidget(self.ratelabel)
        hlayout2.addStretch()
        hlayout2.addWidget(self.datelabel)
        hlayout2.addStretch()
        hlayout2.addWidget(self.log_button)

        layout = QVBoxLayout()
        layout.addLayout(hlayout1)
        layout.addLayout(hlayout2)
        layout.addWidget(self.treewidget)
        self.setLayout(layout)

        self.process = None
        self.set_running_state(False)

        if not is_pylint_installed():
            for widget in (self.treewidget, self.filecombo, self.start_button,
                           self.stop_button):
                widget.setDisabled(True)
            text = translate('Pylint', 'Please install <b>pylint</b>:')
            url = 'http://www.logilab.fr'
            text += ' <a href=%s>%s</a>' % (url, url)
            self.ratelabel.setText(text)
        else:
            self.show_data()