INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
Setup table
def setup_table(self): """Setup table""" self.horizontalHeader().setStretchLastSection(True) self.adjust_columns() self.columnAt(0) # Sorting columns self.setSortingEnabled(False) self.sortByColumn(0, Qt.DescendingOrder)
Reimplement Qt method
def mouseDoubleClickEvent(self, event): """Reimplement Qt method""" index_clicked = self.indexAt(event.pos()) if self.model.breakpoints: filename = self.model.breakpoints[index_clicked.row()][0] line_number_str = self.model.breakpoints[index_clicked.row()][1] ...
Get the list of languages we need to start servers and create clients for.
def get_languages(self): """ Get the list of languages we need to start servers and create clients for. """ languages = ['python'] all_options = CONF.options(self.CONF_SECTION) for option in all_options: if option in [l.lower() for l in LSP_LANGUAGES]:...
Get root path to pass to the LSP servers. This can be the current project path or the output of getcwd_or_home (except for Python, see below).
def get_root_path(self, language): """ Get root path to pass to the LSP servers. This can be the current project path or the output of getcwd_or_home (except for Python, see below). """ path = None # Get path of the current project if self.main and self....
Send a new initialize message to each LSP server when the project path has changed so they can update the respective server root paths.
def reinitialize_all_clients(self): """ Send a new initialize message to each LSP server when the project path has changed so they can update the respective server root paths. """ for language in self.clients: language_client = self.clients[language] if la...
Start an LSP client for a given language.
def start_client(self, language): """Start an LSP client for a given language.""" started = False if language in self.clients: language_client = self.clients[language] queue = self.register_queue[language] # Don't start LSP services when testing unless we dem...
Update Python server configuration with the options saved in our config system.
def generate_python_config(self): """ Update Python server configuration with the options saved in our config system. """ python_config = PYTHON_CONFIG.copy() # Server options cmd = self.get_option('advanced/command_launch') host = self.get_option('advanc...
Setup config page widgets and options.
def setup_page(self): """Setup config page widgets and options.""" settings_group = QGroupBox(_("Settings")) hist_spin = self.create_spinbox( _("History depth: "), _(" entries"), 'max_entries', min_=10, max_=10000, step=10, ...
Transcode a text string
def transcode(text, input=PREFERRED_ENCODING, output=PREFERRED_ENCODING): """Transcode a text string""" try: return text.decode("cp437").encode("cp1252") except UnicodeError: try: return text.decode("cp437").encode(output) except UnicodeError: return t...
Return a unicode version of string decoded using the file system encoding.
def to_unicode_from_fs(string): """ Return a unicode version of string decoded using the file system encoding. """ if not is_string(string): # string is a QString string = to_text_string(string.toUtf8(), 'utf-8') else: if is_binary_string(string): try: ...
Return a byte string version of unic encoded using the file system encoding.
def to_fs_from_unicode(unic): """ Return a byte string version of unic encoded using the file system encoding. """ if is_unicode(unic): try: string = unic.encode(FS_ENCODING) except (UnicodeError, TypeError): pass else: return s...
Function to get the coding of a text. @param text text to inspect (string) @return coding string
def get_coding(text, force_chardet=False): """ Function to get the coding of a text. @param text text to inspect (string) @return coding string """ if not force_chardet: for line in text.splitlines()[:2]: try: result = CODING_RE.search(to_text_string(...
Function to decode a text. @param text text to decode (string) @return decoded text and encoding
def decode(text): """ Function to decode a text. @param text text to decode (string) @return decoded text and encoding """ try: if text.startswith(BOM_UTF8): # UTF-8 with BOM return to_text_string(text[len(BOM_UTF8):], 'utf-8'), 'utf-8-bom' elif ...
Convert a string to unicode
def to_unicode(string): """Convert a string to unicode""" if not is_unicode(string): for codec in CODECS: try: unic = to_text_string(string, codec) except UnicodeError: pass except TypeError: break ...
Write 'text' to file ('filename') assuming 'encoding' in an atomic way Return (eventually new) encoding
def write(text, filename, encoding='utf-8', mode='wb'): """ Write 'text' to file ('filename') assuming 'encoding' in an atomic way Return (eventually new) encoding """ text, encoding = encode(text, encoding) if 'a' in mode: with open(filename, mode) as textfile: textf...
Write 'lines' to file ('filename') assuming 'encoding' Return (eventually new) encoding
def writelines(lines, filename, encoding='utf-8', mode='wb'): """ Write 'lines' to file ('filename') assuming 'encoding' Return (eventually new) encoding """ return write(os.linesep.join(lines), filename, encoding, mode)
Read text from file ('filename') Return text and encoding
def read(filename, encoding='utf-8'): """ Read text from file ('filename') Return text and encoding """ text, encoding = decode( open(filename, 'rb').read() ) return text, encoding
Read lines from file ('filename') Return lines and encoding
def readlines(filename, encoding='utf-8'): """ Read lines from file ('filename') Return lines and encoding """ text, encoding = read(filename, encoding) return text.split(os.linesep), encoding
Return all file type extensions supported by Pygments
def _get_pygments_extensions(): """Return all file type extensions supported by Pygments""" # NOTE: Leave this import here to keep startup process fast! import pygments.lexers as lexers extensions = [] for lx in lexers.get_all_lexers(): lexer_exts = lx[2] if lexer_exts: ...
Return filter associated to file extension
def get_filter(filetypes, ext): """Return filter associated to file extension""" if not ext: return ALL_FILTER for title, ftypes in filetypes: if ext in ftypes: return _create_filter(title, ftypes) else: return ''
Get all file types supported by the Editor
def get_edit_filetypes(): """Get all file types supported by the Editor""" # The filter details are not hidden on Windows, so we can't use # all Pygments extensions on that platform if os.name == 'nt': supported_exts = [] else: try: supported_exts = _get_pygments_extensio...
Detect if we are running in an Ubuntu-based distribution
def is_ubuntu(): """Detect if we are running in an Ubuntu-based distribution""" if sys.platform.startswith('linux') and osp.isfile('/etc/lsb-release'): release_info = open('/etc/lsb-release').read() if 'Ubuntu' in release_info: return True else: return False e...
Detect if we are running in a Gtk-based desktop
def is_gtk_desktop(): """Detect if we are running in a Gtk-based desktop""" if sys.platform.startswith('linux'): xdg_desktop = os.environ.get('XDG_CURRENT_DESKTOP', '') if xdg_desktop: gtk_desktops = ['Unity', 'GNOME', 'XFCE'] if any([xdg_desktop.startswith(d) for d in gt...
Detect if we are running in a KDE desktop
def is_kde_desktop(): """Detect if we are running in a KDE desktop""" if sys.platform.startswith('linux'): xdg_desktop = os.environ.get('XDG_CURRENT_DESKTOP', '') if xdg_desktop: if 'KDE' in xdg_desktop: return True else: return False ...
Return PYTHONPATH list as relative paths
def _get_relative_pythonpath(self): """Return PYTHONPATH list as relative paths""" # Workaround to replace os.path.relpath (new in Python v2.6): offset = len(self.root_path)+len(os.pathsep) return [path[offset:] for path in self.pythonpath]
Set PYTHONPATH list relative paths
def _set_relative_pythonpath(self, value): """Set PYTHONPATH list relative paths""" self.pythonpath = [osp.abspath(osp.join(self.root_path, path)) for path in value]
Return True if dirname is in project's PYTHONPATH
def is_in_pythonpath(self, dirname): """Return True if dirname is in project's PYTHONPATH""" return fixpath(dirname) in [fixpath(_p) for _p in self.pythonpath]
Remove path from project's PYTHONPATH Return True if path was removed, False if it was not found
def remove_from_pythonpath(self, path): """Remove path from project's PYTHONPATH Return True if path was removed, False if it was not found""" pathlist = self.get_pythonpath() if path in pathlist: pathlist.pop(pathlist.index(path)) self.set_pythonpath(pathli...
Add path to project's PYTHONPATH Return True if path was added, False if it was already there
def add_to_pythonpath(self, path): """Add path to project's PYTHONPATH Return True if path was added, False if it was already there""" pathlist = self.get_pythonpath() if path in pathlist: return False else: pathlist.insert(0, path) sel...
Return data files for package *name* with extensions in *extlist*
def get_package_data(name, extlist): """Return data files for package *name* with extensions in *extlist*""" flist = [] # Workaround to replace os.path.relpath (not available until Python 2.6): offset = len(name)+len(os.pathsep) for dirpath, _dirnames, filenames in os.walk(name): for fname i...
Return subpackages of package *name*
def get_subpackages(name): """Return subpackages of package *name*""" splist = [] for dirpath, _dirnames, _filenames in os.walk(name): if osp.isfile(osp.join(dirpath, '__init__.py')): splist.append(".".join(dirpath.split(os.sep))) return splist
Return Python documentation path (Windows: return the PythonXX.chm path if available)
def get_python_doc_path(): """ Return Python documentation path (Windows: return the PythonXX.chm path if available) """ if os.name == 'nt': doc_path = osp.join(sys.prefix, "Doc") if not osp.isdir(doc_path): return python_chm = [path for path in os.listdi...
Set the OpenGL implementation used by Spyder. See issue 7447 for the details.
def set_opengl_implementation(option): """ Set the OpenGL implementation used by Spyder. See issue 7447 for the details. """ if option == 'software': QCoreApplication.setAttribute(Qt.AA_UseSoftwareOpenGL) if QQuickWindow is not None: QQuickWindow.setSceneGraphBa...
Setup logging with cli options defined by the user.
def setup_logging(cli_options): """Setup logging with cli options defined by the user.""" if cli_options.debug_info or get_debug_level() > 0: levels = {2: logging.INFO, 3: logging.DEBUG} log_level = levels[get_debug_level()] log_format = '%(asctime)s [%(levelname)s] [%(name)s] -> %(...
Qt warning messages are intercepted by this handler. On some operating systems, warning messages might be displayed even if the actual message does not apply. This filter adds a blacklist for messages that are being printed for no apparent reason. Anything else will get printed in the internal con...
def qt_message_handler(msg_type, msg_log_context, msg_string): """ Qt warning messages are intercepted by this handler. On some operating systems, warning messages might be displayed even if the actual message does not apply. This filter adds a blacklist for messages that are being printed fo...
Initialize Qt, patching sys.exit and eventually setting up ETS
def initialize(): """Initialize Qt, patching sys.exit and eventually setting up ETS""" # This doesn't create our QApplication, just holds a reference to # MAIN_APP, created above to show our splash screen as early as # possible app = qapplication() # --- Set application icon app.set...
Create and show Spyder's main window Start QApplication event loop
def run_spyder(app, options, args): """ Create and show Spyder's main window Start QApplication event loop """ #TODO: insert here # Main window main = MainWindow(options) try: main.setup() except BaseException: if main.console is not None: try:...
Main function
def main(): """Main function""" # **** For Pytest **** # We need to create MainWindow **here** to avoid passing pytest # options to Spyder if running_under_pytest(): try: from unittest.mock import Mock except ImportError: from mock import Mock # Pyth...
Create and return toolbar with *title* and *object_name*
def create_toolbar(self, title, object_name, iconsize=24): """Create and return toolbar with *title* and *object_name*""" toolbar = self.addToolBar(title) toolbar.setObjectName(object_name) toolbar.setIconSize(QSize(iconsize, iconsize)) self.toolbarslist.append(toolbar) ...
Setup main window
def setup(self): """Setup main window""" logger.info("*** Start of MainWindow setup ***") logger.info("Applying theme configuration...") ui_theme = CONF.get('appearance', 'ui_theme') color_scheme = CONF.get('appearance', 'selected') if ui_theme == 'dark': ...
Actions to be performed only after the main window's `show` method was triggered
def post_visible_setup(self): """Actions to be performed only after the main window's `show` method was triggered""" self.restore_scrollbar_position.emit() # [Workaround for Issue 880] # QDockWidget objects are not painted if restored as floating # windows, so we ...
Set window title.
def set_window_title(self): """Set window title.""" if DEV is not None: title = u"Spyder %s (Python %s.%s)" % (__version__, sys.version_info[0], sys.version_info[1]) else: ...
Show a QMessageBox with a list of missing hard dependencies
def report_missing_dependencies(self): """Show a QMessageBox with a list of missing hard dependencies""" missing_deps = dependencies.missing_dependencies() if missing_deps: QMessageBox.critical(self, _('Error'), _("<b>You have missing dependencies!</b>" ...
Load window layout settings from userconfig-based configuration with *prefix*, under *section* default: if True, do not restore inner layout
def load_window_settings(self, prefix, default=False, section='main'): """Load window layout settings from userconfig-based configuration with *prefix*, under *section* default: if True, do not restore inner layout""" get_func = CONF.get_default if default else CONF.get wind...
Return current window settings Symetric to the 'set_window_settings' setter
def get_window_settings(self): """Return current window settings Symetric to the 'set_window_settings' setter""" window_size = (self.window_size.width(), self.window_size.height()) is_fullscreen = self.isFullScreen() if is_fullscreen: is_maximized = self.maximiz...
Set window settings Symetric to the 'get_window_settings' accessor
def set_window_settings(self, hexstate, window_size, prefs_dialog_size, pos, is_maximized, is_fullscreen): """Set window settings Symetric to the 'get_window_settings' accessor""" self.setUpdatesEnabled(False) self.window_size = QSize(window_size[0], wind...
Save current window settings with *prefix* in the userconfig-based configuration, under *section*
def save_current_window_settings(self, prefix, section='main', none_state=False): """Save current window settings with *prefix* in the userconfig-based configuration, under *section*""" win_size = self.window_size prefs_size = self.prefs_dialog_s...
Tabify plugin dockwigdets
def tabify_plugins(self, first, second): """Tabify plugin dockwigdets""" self.tabifyDockWidget(first.dockwidget, second.dockwidget)
Setup window layout
def setup_layout(self, default=False): """Setup window layout""" prefix = 'window' + '/' settings = self.load_window_settings(prefix, default) hexstate = settings[0] self.first_spyder_run = False if hexstate is None: # First Spyder execution: ...
Setup default layouts when run for the first time.
def setup_default_layouts(self, index, settings): """Setup default layouts when run for the first time.""" self.setUpdatesEnabled(False) first_spyder_run = bool(self.first_spyder_run) # Store copy if first_spyder_run: self.set_window_settings(*settings) els...
Reset window layout to default
def reset_window_layout(self): """Reset window layout to default""" answer = QMessageBox.warning(self, _("Warning"), _("Window layout will be reset to default settings: " "this affects window position, size and dockwidgets.\n" "Do y...
Save layout dialog
def quick_layout_save(self): """Save layout dialog""" get = CONF.get set_ = CONF.set names = get('quick_layouts', 'names') order = get('quick_layouts', 'order') active = get('quick_layouts', 'active') dlg = self.dialog_layout_save(self, names) ...
Layout settings dialog
def quick_layout_settings(self): """Layout settings dialog""" get = CONF.get set_ = CONF.set section = 'quick_layouts' names = get(section, 'names') order = get(section, 'order') active = get(section, 'active') dlg = self.dialog_layout_settin...
Switch to quick layout number *index*
def quick_layout_switch(self, index): """Switch to quick layout number *index*""" section = 'quick_layouts' try: settings = self.load_window_settings('layout_{}/'.format(index), section=section) (hexstate, window_si...
Update the text displayed in the menu entry.
def _update_show_toolbars_action(self): """Update the text displayed in the menu entry.""" if self.toolbars_visible: text = _("Hide toolbars") tip = _("Hide toolbars") else: text = _("Show toolbars") tip = _("Show toolbars") self.sh...
Saves the name of the visible toolbars in the .ini file.
def save_visible_toolbars(self): """Saves the name of the visible toolbars in the .ini file.""" toolbars = [] for toolbar in self.visible_toolbars: toolbars.append(toolbar.objectName()) CONF.set('main', 'last_visible_toolbars', toolbars)
Collects the visible toolbars.
def get_visible_toolbars(self): """Collects the visible toolbars.""" toolbars = [] for toolbar in self.toolbarslist: if toolbar.toggleViewAction().isChecked(): toolbars.append(toolbar) self.visible_toolbars = toolbars
Loads the last visible toolbars from the .ini file.
def load_last_visible_toolbars(self): """Loads the last visible toolbars from the .ini file.""" toolbars_names = CONF.get('main', 'last_visible_toolbars', default=[]) if toolbars_names: dic = {} for toolbar in self.toolbarslist: dic[toolbar.objectN...
Show/Hides toolbars.
def show_toolbars(self): """Show/Hides toolbars.""" value = not self.toolbars_visible CONF.set('main', 'toolbars_visible', value) if value: self.save_visible_toolbars() else: self.get_visible_toolbars() for toolbar in self.visible_toolbar...
Handle an invalid active project.
def valid_project(self): """Handle an invalid active project.""" try: path = self.projects.get_active_project_path() except AttributeError: return if bool(path): if not self.projects.is_valid_project(path): if path: ...
Show action shortcuts in menu
def show_shortcuts(self, menu): """Show action shortcuts in menu""" for element in getattr(self, menu + '_menu_actions'): if element and isinstance(element, QAction): if element._shown_shortcut is not None: element.setShortcut(element._shown_shortcut)
Hide action shortcuts in menu
def hide_shortcuts(self, menu): """Hide action shortcuts in menu""" for element in getattr(self, menu + '_menu_actions'): if element and isinstance(element, QAction): if element._shown_shortcut is not None: element.setShortcut(QKeySequence())
Get properties of focus widget Returns tuple (widget, properties) where properties is a tuple of booleans: (is_console, not_readonly, readwrite_editor)
def get_focus_widget_properties(self): """Get properties of focus widget Returns tuple (widget, properties) where properties is a tuple of booleans: (is_console, not_readonly, readwrite_editor)""" from spyder.plugins.editor.widgets.editor import TextEditBaseWidget from spyde...
Update edit menu
def update_edit_menu(self): """Update edit menu""" widget, textedit_properties = self.get_focus_widget_properties() if textedit_properties is None: # widget is not an editor/console return # !!! Below this line, widget is expected to be a QPlainTextEdit # in...
Update search menu
def update_search_menu(self): """Update search menu""" # Disabling all actions except the last one # (which is Find in files) to begin with for child in self.search_menu.actions()[:-1]: child.setEnabled(False) widget, textedit_properties = self.get_focus_widge...
Set splash message
def set_splash(self, message): """Set splash message""" if self.splash is None: return if message: logger.info(message) self.splash.show() self.splash.showMessage(message, Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAb...
closeEvent reimplementation
def closeEvent(self, event): """closeEvent reimplementation""" if self.closing(True): event.accept() else: event.ignore()
Reimplement Qt method
def resizeEvent(self, event): """Reimplement Qt method""" if not self.isMaximized() and not self.fullscreen_flag: self.window_size = self.size() QMainWindow.resizeEvent(self, event) # To be used by the tour to be able to resize self.sig_resized.emit(event)
Reimplement Qt method
def moveEvent(self, event): """Reimplement Qt method""" if not self.isMaximized() and not self.fullscreen_flag: self.window_position = self.pos() QMainWindow.moveEvent(self, event) # To be used by the tour to be able to move self.sig_moved.emit(event)
Reimplement Qt method
def hideEvent(self, event): """Reimplement Qt method""" try: for plugin in (self.widgetlist + self.thirdparty_plugins): if plugin.isAncestorOf(self.last_focused_widget): plugin.visibility_changed(True) QMainWindow.hideEvent(self, event) ...
To keep track of to the last focused widget
def change_last_focused_widget(self, old, now): """To keep track of to the last focused widget""" if (now is None and QApplication.activeWindow() is not None): QApplication.activeWindow().setFocus() self.last_focused_widget = QApplication.focusWidget() elif now is no...
Exit tasks
def closing(self, cancelable=False): """Exit tasks""" if self.already_closed or self.is_starting_up: return True if cancelable and CONF.get('main', 'prompt_on_exit'): reply = QMessageBox.critical(self, 'Spyder', 'Do you reall...
Add QDockWidget and toggleViewAction
def add_dockwidget(self, child): """Add QDockWidget and toggleViewAction""" dockwidget, location = child.create_dockwidget() if CONF.get('main', 'vertical_dockwidget_titlebars'): dockwidget.setFeatures(dockwidget.features()| QDockWidget.DockWid...
Lock/Unlock dockwidgets and toolbars
def toggle_lock(self, value): """Lock/Unlock dockwidgets and toolbars""" self.interface_locked = value CONF.set('main', 'panes_locked', value) # Apply lock to panes for plugin in (self.widgetlist + self.thirdparty_plugins): if self.interface_locked: ...
Shortcut: Ctrl+Alt+Shift+M First call: maximize current dockwidget Second call (or restore=True): restore original window layout
def maximize_dockwidget(self, restore=False): """Shortcut: Ctrl+Alt+Shift+M First call: maximize current dockwidget Second call (or restore=True): restore original window layout""" if self.state_before_maximizing is None: if restore: return ...
Add widget actions to toolbar
def add_to_toolbar(self, toolbar, widget): """Add widget actions to toolbar""" actions = widget.toolbar_actions if actions is not None: add_actions(toolbar, actions)
Create About Spyder dialog with general information.
def about(self): """Create About Spyder dialog with general information.""" versions = get_versions() # Show Git revision for development version revlink = '' if versions['revision']: rev = versions['revision'] revlink = " (<a href='https://github.c...
Show Spyder's Dependencies dialog box
def show_dependencies(self): """Show Spyder's Dependencies dialog box""" from spyder.widgets.dependencies import DependenciesDialog dlg = DependenciesDialog(self) dlg.set_data(dependencies.DEPENDENCIES) dlg.exec_()
Render issue before sending it to Github
def render_issue(self, description='', traceback=''): """Render issue before sending it to Github""" # Get component versions versions = get_versions() # Get git revision for development version revision = '' if versions['revision']: revision = versio...
Report a Spyder issue to github, generating body text if needed.
def report_issue(self, body=None, title=None, open_webpage=False): """Report a Spyder issue to github, generating body text if needed.""" if body is None: from spyder.widgets.reporterror import SpyderErrorDialog report_dlg = SpyderErrorDialog(self, is_report=True) ...
Global callback
def global_callback(self): """Global callback""" widget = QApplication.focusWidget() action = self.sender() callback = from_qvariant(action.data(), to_text_string) from spyder.plugins.editor.widgets.editor import TextEditBaseWidget from spyder.plugins.ipythonconsole...
Open external console
def open_external_console(self, fname, wdir, args, interact, debug, python, python_args, systerm, post_mortem=False): """Open external console""" if systerm: # Running script in an external system terminal try: if CONF.get('main...
Execute lines in IPython console and eventually set focus to the Editor.
def execute_in_external_console(self, lines, focus_to_editor): """ Execute lines in IPython console and eventually set focus to the Editor. """ console = self.ipyconsole console.switch_to_plugin() console.execute_code(lines) if focus_to_editor: ...
Open filename with the appropriate application Redirect to the right widget (txt -> editor, spydata -> workspace, ...) or open file outside Spyder (if extension is not supported)
def open_file(self, fname, external=False): """ Open filename with the appropriate application Redirect to the right widget (txt -> editor, spydata -> workspace, ...) or open file outside Spyder (if extension is not supported) """ fname = to_text_string(fname) ...
Open external files that can be handled either by the Editor or the variable explorer inside Spyder.
def open_external_file(self, fname): """ Open external files that can be handled either by the Editor or the variable explorer inside Spyder. """ fname = encoding.to_unicode_from_fs(fname) if osp.isfile(fname): self.open_file(fname, external=True) ...
Return Spyder PYTHONPATH
def get_spyder_pythonpath(self): """Return Spyder PYTHONPATH""" active_path = [p for p in self.path if p not in self.not_active_path] return active_path + self.project_path
Add Spyder path to sys.path
def add_path_to_sys_path(self): """Add Spyder path to sys.path""" for path in reversed(self.get_spyder_pythonpath()): sys.path.insert(1, path)
Remove Spyder path from sys.path
def remove_path_from_sys_path(self): """Remove Spyder path from sys.path""" for path in self.path + self.project_path: while path in sys.path: sys.path.remove(path)
Spyder path manager
def path_manager_callback(self): """Spyder path manager""" from spyder.widgets.pathmanager import PathManager self.remove_path_from_sys_path() project_path = self.projects.get_pythonpath() dialog = PathManager(self, self.path, project_path, self...
Projects PYTHONPATH contribution has changed
def pythonpath_changed(self): """Projects PYTHONPATH contribution has changed""" self.remove_path_from_sys_path() self.project_path = self.projects.get_pythonpath() self.add_path_to_sys_path() self.sig_pythonpath_changed.emit()
Apply settings changed in 'Preferences' dialog box
def apply_settings(self): """Apply settings changed in 'Preferences' dialog box""" qapp = QApplication.instance() # Set 'gtk+' as the default theme in Gtk-based desktops # Fixes Issue 2036 if is_gtk_desktop() and ('GTK+' in QStyleFactory.keys()): try: ...
Update dockwidgets features settings
def apply_panes_settings(self): """Update dockwidgets features settings""" for plugin in (self.widgetlist + self.thirdparty_plugins): features = plugin.FEATURES if CONF.get('main', 'vertical_dockwidget_titlebars'): features = features | QDockWidget.DockWidget...
Update status bar widgets settings
def apply_statusbar_settings(self): """Update status bar widgets settings""" show_status_bar = CONF.get('main', 'show_status_bar') self.statusBar().setVisible(show_status_bar) if show_status_bar: for widget, name in ((self.mem_status, 'memory_usage'), ...
Edit Spyder preferences
def edit_preferences(self): """Edit Spyder preferences""" from spyder.preferences.configdialog import ConfigDialog dlg = ConfigDialog(self) dlg.size_change.connect(self.set_prefs_size) if self.prefs_dialog_size is not None: dlg.resize(self.prefs_dialog_size) ...
Register QAction or QShortcut to Spyder main application, with shortcut (context, name, default)
def register_shortcut(self, qaction_or_qshortcut, context, name, add_sc_to_tip=False): """ Register QAction or QShortcut to Spyder main application, with shortcut (context, name, default) """ self.shortcut_data.append( (qaction_or_qshortcut, contex...
Apply shortcuts settings to all widgets/plugins
def apply_shortcuts(self): """Apply shortcuts settings to all widgets/plugins""" toberemoved = [] for index, (qobject, context, name, add_sc_to_tip) in enumerate(self.shortcut_data): keyseq = QKeySequence( get_shortcut(context, name) ) try: ...
Quit and reset Spyder and then Restart application.
def reset_spyder(self): """ Quit and reset Spyder and then Restart application. """ answer = QMessageBox.warning(self, _("Warning"), _("Spyder will restart and reset to default settings: <br><br>" "Do you want to continue?"), QMessageBox.Ye...
Quit and Restart Spyder application. If reset True it allows to reset spyder on restart.
def restart(self, reset=False): """ Quit and Restart Spyder application. If reset True it allows to reset spyder on restart. """ # Get start path to use in restart script spyder_start_directory = get_module_path('spyder') restart_script = osp.join(spyder_...
Show interactive tour.
def show_tour(self, index): """Show interactive tour.""" self.maximize_dockwidget(restore=True) frames = self.tours_available[index] self.tour.set_tour(index, frames, self) self.tour.start_tour()
Open file list management dialog box.
def open_fileswitcher(self, symbol=False): """Open file list management dialog box.""" if self.fileswitcher is not None and \ self.fileswitcher.is_visible: self.fileswitcher.hide() self.fileswitcher.is_visible = False return if symbol: ...