Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def toggle_line_numbers(self, checked): if self.tabwidget is None: return for editor in self.editors: editor.toggle_line_numbers(linenumbers=checked, markers=False) self.set_option('line_numbers', checked)
[ "Toggle line numbers." ]
Please provide a description of the function:def document_did_save_notification(self, params): text = None if 'text' in params: text = params['text'] params = { 'textDocument': { 'uri': path_as_uri(params['file']) } } i...
[ "\n Handle the textDocument/didSave message received from an LSP server.\n " ]
Please provide a description of the function:def acceptNavigationRequest(self, url, navigation_type, isMainFrame): if navigation_type == QWebEnginePage.NavigationTypeLinkClicked: self.linkClicked.emit(url) return False return True
[ "\r\n Overloaded method to handle links ourselves\r\n " ]
Please provide a description of the function:def find_text(self, text, changed=True, forward=True, case=False, words=False, regexp=False): if not WEBENGINE: findflag = QWebEnginePage.FindWrapsAroundDocument else: findflag = 0 ...
[ "Find text" ]
Please provide a description of the function:def apply_zoom_factor(self): if hasattr(self, 'setZoomFactor'): # Assuming Qt >=v4.5 self.setZoomFactor(self.zoom_factor) else: # Qt v4.4 self.setTextSizeMultiplier(self.zoom_factor)
[ "Apply zoom factor" ]
Please provide a description of the function:def setHtml(self, html, baseUrl=QUrl()): if WEBENGINE: self.setEnabled(False) super(WebView, self).setHtml(html, baseUrl) self.setEnabled(True) else: super(WebView, self).setHtml(html, baseUrl)
[ "\r\n Reimplement Qt method to prevent WebEngine to steal focus\r\n when setting html on the page\r\n\r\n Solution taken from\r\n https://bugreports.qt.io/browse/QTBUG-52999\r\n " ]
Please provide a description of the function:def go_to(self, url_or_text): if is_text_string(url_or_text): url = QUrl(url_or_text) else: url = url_or_text self.webview.load(url)
[ "Go to page *address*" ]
Please provide a description of the function:def url_combo_activated(self, valid): text = to_text_string(self.url_combo.currentText()) self.go_to(self.text_to_url(text))
[ "Load URL from combo box first item" ]
Please provide a description of the function:def initialize_plugin(self): self.create_toggle_view_action() self.plugin_actions = self.get_plugin_actions() + [MENU_SEPARATOR, self.undock_action] add_actions(self.options_menu, se...
[ "\n Initialize plugin: connect signals, setup actions, etc.\n\n It must be run at the end of __init__\n " ]
Please provide a description of the function:def register_shortcut(self, qaction_or_qshortcut, context, name, add_sc_to_tip=False): self.main.register_shortcut(qaction_or_qshortcut, context, name, add_sc_to_tip)
[ "\n Register QAction or QShortcut to Spyder main application.\n\n if add_sc_to_tip is True, the shortcut is added to the\n action's tooltip\n " ]
Please provide a description of the function:def register_widget_shortcuts(self, widget): for qshortcut, context, name in widget.get_shortcut_data(): self.register_shortcut(qshortcut, context, name)
[ "\n Register widget shortcuts.\n\n Widget interface must have a method called 'get_shortcut_data'\n " ]
Please provide a description of the function:def visibility_changed(self, enable): if self.dockwidget is None: return if enable: self.dockwidget.raise_() widget = self.get_focus_widget() if widget is not None and self.undocked_window is not None: ...
[ "\n Dock widget visibility has changed.\n " ]
Please provide a description of the function:def set_option(self, option, value): CONF.set(self.CONF_SECTION, str(option), value)
[ "\n Set a plugin option in configuration file.\n\n Note: Use sig_option_changed to call it from widgets of the\n same or another plugin.\n " ]
Please provide a description of the function:def starting_long_process(self, message): self.show_message(message) QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) QApplication.processEvents()
[ "\n Showing message in main window's status bar.\n\n This also changes mouse cursor to Qt.WaitCursor\n " ]
Please provide a description of the function:def ending_long_process(self, message=""): QApplication.restoreOverrideCursor() self.show_message(message, timeout=2000) QApplication.processEvents()
[ "\n Clear main window's status bar and restore mouse cursor.\n " ]
Please provide a description of the function:def show_compatibility_message(self, message): messageBox = QMessageBox(self) messageBox.setWindowModality(Qt.NonModal) messageBox.setAttribute(Qt.WA_DeleteOnClose) messageBox.setWindowTitle('Compatibility Check') messageBox.s...
[ "\n Show compatibility message.\n " ]
Please provide a description of the function:def refresh_actions(self): self.options_menu.clear() # Decide what additional actions to show if self.undocked_window is None: additional_actions = [MENU_SEPARATOR, self.undock_action, ...
[ "\n Create options menu.\n " ]
Please provide a description of the function:def _key_paren_left(self, text): self.current_prompt_pos = self.parentWidget()._prompt_pos if self.get_current_line_to_cursor(): last_obj = self.get_last_obj() if last_obj and not last_obj.isdigit(): self.show_...
[ " Action for '(' " ]
Please provide a description of the function:def keyPressEvent(self, event): event, text, key, ctrl, shift = restore_keyevent(event) if key == Qt.Key_ParenLeft and not self.has_selected_text() \ and self.help_enabled and not self.parent()._reading: self._key_paren_left(tex...
[ "Reimplement Qt Method - Basic keypress event handler" ]
Please provide a description of the function:def focusInEvent(self, event): self.focus_changed.emit() return super(ControlWidget, self).focusInEvent(event)
[ "Reimplement Qt method to send focus change notification" ]
Please provide a description of the function:def focusOutEvent(self, event): self.focus_changed.emit() return super(ControlWidget, self).focusOutEvent(event)
[ "Reimplement Qt method to send focus change notification" ]
Please provide a description of the function:def keyPressEvent(self, event): event, text, key, ctrl, shift = restore_keyevent(event) if key == Qt.Key_Slash and self.isVisible(): self.show_find_widget.emit()
[ "Reimplement Qt Method - Basic keypress event handler" ]
Please provide a description of the function:def focusInEvent(self, event): self.focus_changed.emit() return super(PageControlWidget, self).focusInEvent(event)
[ "Reimplement Qt method to send focus change notification" ]
Please provide a description of the function:def focusOutEvent(self, event): self.focus_changed.emit() return super(PageControlWidget, self).focusOutEvent(event)
[ "Reimplement Qt method to send focus change notification" ]
Please provide a description of the function:def get_screen_resolution(self): widget = QDesktopWidget() geometry = widget.availableGeometry(widget.primaryScreen()) return geometry.width(), geometry.height()
[ "Return the screen resolution of the primary screen." ]
Please provide a description of the function:def set_current_widget(self, fig_browser): self.stack.setCurrentWidget(fig_browser) # We update the actions of the options button (cog menu) and # we move it to the layout of the current widget. self.refresh_actions() fig_brow...
[ "\n Set the currently visible fig_browser in the stack widget, refresh the\n actions of the cog menu button and move it to the layout of the new\n fig_browser.\n " ]
Please provide a description of the function:def add_shellwidget(self, shellwidget): shellwidget_id = id(shellwidget) if shellwidget_id not in self.shellwidgets: self.options_button.setVisible(True) fig_browser = FigureBrowser( self, options_button=self.o...
[ "\n Register shell with figure explorer.\n\n This function opens a new FigureBrowser for browsing the figures\n in the shell.\n " ]
Please provide a description of the function:def apply_plugin_settings(self, options): for fig_browser in list(self.shellwidgets.values()): fig_browser.setup(**self.get_settings())
[ "Apply configuration file's plugin settings" ]
Please provide a description of the function:def flags(self, index): if not index.isValid(): return Qt.ItemIsEnabled column = index.column() if column in [0]: return Qt.ItemFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.I...
[ "Override Qt method" ]
Please provide a description of the function:def data(self, index, role=Qt.DisplayRole): if not index.isValid() or not 0 <= index.row() < len(self._rows): return to_qvariant() row = index.row() column = index.column() name, state = self.row(row) if...
[ "Override Qt method" ]
Please provide a description of the function:def setData(self, index, value, role): row = index.row() name, state = self.row(row) if role == Qt.CheckStateRole: self.set_row(row, [name, not state]) self._parent.setCurrentIndex(index) self._par...
[ "Override Qt method" ]
Please provide a description of the function:def check_text(self, text): if to_text_string(text) == u'': self.button_ok.setEnabled(False) else: self.button_ok.setEnabled(True)
[ "Disable empty layout name possibility" ]
Please provide a description of the function:def temp_fail_retry(error, fun, *args): while 1: try: return fun(*args) except error as e: eintr = errno.WSAEINTR if os.name == 'nt' else errno.EINTR if e.args[0] == eintr: continue ...
[ "Retry to execute function, ignoring EINTR error (interruptions)" ]
Please provide a description of the function:def write_packet(sock, data, already_pickled=False): if already_pickled: sent_data = data else: sent_data = pickle.dumps(data, PICKLE_HIGHEST_PROTOCOL) sent_data = struct.pack("l", len(sent_data)) + sent_data nsend = len(sent_data)...
[ "Write *data* to socket *sock*" ]
Please provide a description of the function:def read_packet(sock, timeout=None): sock.settimeout(timeout) dlen, data = None, None try: if os.name == 'nt': # Windows implementation datalen = sock.recv(SZ) dlen, = struct.unpack("l", datalen) ...
[ "\r\n Read data from socket *sock*\r\n Returns None if something went wrong\r\n " ]
Please provide a description of the function:def communicate(sock, command, settings=[]): try: COMMUNICATE_LOCK.acquire() write_packet(sock, command) for option in settings: write_packet(sock, option) return read_packet(sock) finally: COMMUNICATE...
[ "Communicate with monitor" ]
Please provide a description of the function:def gettime_s(text): pattern = r'([+-]?\d+\.?\d*) ?([munsecinh]+)' matches = re.findall(pattern, text) if len(matches) == 0: return None time = 0. for res in matches: tmp = float(res[0]) if res[1] == 'ns': ...
[ "\r\n Parse text and return a time in seconds.\r\n\r\n The text is of the format 0h : 0.min:0.0s:0 ms:0us:0 ns.\r\n Spaces are not taken into account and any of the specifiers can be ignored.\r\n " ]
Please provide a description of the function:def primes(n): if n==2: return [2] elif n<2: return [] s=list(range(3,n+1,2)) mroot = n ** 0.5 half=(n+1)//2-1 i=0 m=3 while m <= mroot: if s[i]: j=(m*m-3)//2 s[j]=0 ...
[ "\r\n Simple test function\r\n Taken from http://www.huyng.com/posts/python-performance-analysis/\r\n " ]
Please provide a description of the function:def save_data(self): title = _( "Save profiler result") filename, _selfilter = getsavefilename( self, title, getcwd_or_home(), _("Profiler result")+" (*.Result)") if filename: self.datatree.s...
[ "Save data" ]
Please provide a description of the function:def set_item_data(self, item, filename, line_number): set_item_user_text(item, '%s%s%d' % (filename, self.SEP, line_number))
[ "Set tree item user data: filename (string) and line_number (int)" ]
Please provide a description of the function:def get_item_data(self, item): filename, line_number_str = get_item_user_text(item).split(self.SEP) return filename, int(line_number_str)
[ "Get tree item user data: (filename, line_number)" ]
Please provide a description of the function:def initialize_view(self): self.clear() self.item_depth = 0 # To be use for collapsing/expanding one level self.item_list = [] # To be use for collapsing/expanding one level self.items_to_be_shown = {} self.current_vi...
[ "Clean the tree and view parameters" ]
Please provide a description of the function:def load_data(self, profdatafile): import pstats try: stats_indi = [pstats.Stats(profdatafile), ] except (OSError, IOError): return self.profdata = stats_indi[0] if self.compare_file i...
[ "Load profiler data saved by profile/cProfile module" ]
Please provide a description of the function:def find_root(self): self.profdata.sort_stats("cumulative") for func in self.profdata.fcn_list: if ('~', 0) != func[0:2] and not func[2].startswith( '<built-in method exec>'): # This skips the pro...
[ "Find a function without a caller" ]
Please provide a description of the function:def show_tree(self): self.initialize_view() # Clear before re-populating self.setItemsExpandable(True) self.setSortingEnabled(False) rootkey = self.find_root() # This root contains profiler overhead if rootkey: ...
[ "Populate the tree with profiler data and display it." ]
Please provide a description of the function:def function_info(self, functionKey): node_type = 'function' filename, line_number, function_name = functionKey if function_name == '<module>': modulePath, moduleName = osp.split(filename) node_type = 'module' ...
[ "Returns processed information about the function's name and file." ]
Please provide a description of the function:def format_measure(measure): # Convert to a positive value. measure = abs(measure) # For number of calls if isinstance(measure, int): return to_text_string(measure) # For time measurements if 1....
[ "Get format and units for data coming from profiler task." ]
Please provide a description of the function:def color_string(self, x): diff_str = "" color = "black" if len(x) == 2 and self.compare_file is not None: difference = x[0] - x[1] if difference: color, sign = ('green', '-') if difference < 0...
[ "Return a string formatted delta for the values in x.\r\n\r\n Args:\r\n x: 2-item list of integers (representing number of calls) or\r\n 2-item list of floats (representing seconds of runtime).\r\n\r\n Returns:\r\n A list with [formatted x[0], [color, formatted delt...
Please provide a description of the function:def format_output(self, child_key): data = [x.stats.get(child_key, [0, 0, 0, 0, {}]) for x in self.stats1] return (map(self.color_string, islice(zip(*data), 1, 4)))
[ " Formats the data.\r\n\r\n self.stats1 contains a list of one or two pstat.Stats() instances, with\r\n the first being the current run and the second, the saved run, if it\r\n exists. Each Stats instance is a dictionary mapping a function to\r\n 5 data points - cumulative calls, number...
Please provide a description of the function:def populate_tree(self, parentItem, children_list): for child_key in children_list: self.item_depth += 1 (filename, line_number, function_name, file_and_line, node_type ) = self.function_info(child_key) ...
[ "Recursive method to create each item (and associated data) in the tree." ]
Please provide a description of the function:def is_recursive(self, child_item): ancestor = child_item.parent() # FIXME: indexes to data should be defined by a dictionary on init while ancestor: if (child_item.data(0, Qt.DisplayRole ) ==...
[ "Returns True is a function is a descendant of itself." ]
Please provide a description of the function:def get_items(self, maxlevel): itemlist = [] def add_to_itemlist(item, maxlevel, level=1): level += 1 for index in range(item.childCount()): citem = item.child(index) itemlist.append(cite...
[ "Return all items with a level <= `maxlevel`" ]
Please provide a description of the function:def change_view(self, change_in_depth): self.current_view_depth += change_in_depth if self.current_view_depth < 0: self.current_view_depth = 0 self.collapseAll() if self.current_view_depth > 0: for item ...
[ "Change the view depth by expand or collapsing all same-level nodes" ]
Please provide a description of the function:def create_qss_style(color_scheme): def give_font_weight(is_bold): if is_bold: return 'bold' else: return 'normal' def give_font_style(is_italic): if is_italic: return 'italic' else: ...
[ "Returns a QSS stylesheet with Spyder color scheme settings.\n\n The stylesheet can contain classes for:\n Qt: QPlainTextEdit, QFrame, QWidget, etc\n Pygments: .c, .k, .o, etc. (see PygmentsHighlighter)\n IPython: .error, .in-prompt, .out-prompt, etc\n ", "QPlainTextEdit, QTextEdit, Cont...
Please provide a description of the function:def create_pygments_dict(color_scheme_name): def give_font_weight(is_bold): if is_bold: return 'bold' else: return '' def give_font_style(is_italic): if is_italic: return 'italic' else: ...
[ "\n Create a dictionary that saves the given color scheme as a\n Pygments style.\n " ]
Please provide a description of the function:def __remove_pyc_pyo(fname): if osp.splitext(fname)[1] == '.py': for ending in ('c', 'o'): if osp.exists(fname+ending): os.remove(fname+ending)
[ "Eventually remove .pyc and .pyo files associated to a Python script" ]
Please provide a description of the function:def move_file(source, dest): import shutil shutil.copy(source, dest) remove_file(source)
[ "\r\n Move file from *source* to *dest*\r\n If file is a Python script, also rename .pyc and .pyo files if any\r\n " ]
Please provide a description of the function:def onerror(function, path, excinfo): if not os.access(path, os.W_OK): # Is the error an access error? os.chmod(path, stat.S_IWUSR) function(path) else: raise
[ "Error handler for `shutil.rmtree`.\r\n\r\n If the error is due to an access error (read-only file), it\r\n attempts to add write permission and then retries.\r\n If the error is for another reason, it re-raises the error.\r\n\r\n Usage: `shutil.rmtree(path, onerror=onerror)" ]
Please provide a description of the function:def select_port(default_port=20128): import socket while True: try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP) # sock.setso...
[ "Find and return a non used port" ]
Please provide a description of the function:def count_lines(path, extensions=None, excluded_dirnames=None): if extensions is None: extensions = ['.py', '.pyw', '.ipy', '.enaml', '.c', '.h', '.cpp', '.hpp', '.inc', '.', '.hh', '.hxx', '.cc', '.cxx', '.cl...
[ "Return number of source code lines for all filenames in subdirectories\r\n of *path* with names ending with *extensions*\r\n Directory names *excluded_dirnames* will be ignored" ]
Please provide a description of the function:def remove_backslashes(path): if os.name == 'nt': # Removing trailing single backslash if path.endswith('\\') and not path.endswith('\\\\'): path = path[:-1] # Replacing backslashes by slashes path = path.replace('\...
[ "Remove backslashes in *path*\r\n\r\n For Windows platforms only.\r\n Returns the path unchanged on other platforms.\r\n\r\n This is especially useful when formatting path strings on\r\n Windows platforms for which folder paths may contain backslashes\r\n and provoke unicode decoding errors in Python...
Please provide a description of the function:def monkeypatch_method(cls, patch_name): # This function's code was inspired from the following thread: # "[Python-Dev] Monkeypatching idioms -- elegant or ugly?" # by Robert Brewer <fumanchu at aminus.org> # (Tue Jan 15 19:13:25 CET 2008) def ...
[ "\r\n Add the decorated method to the given class; replace as needed.\r\n\r\n If the named method already exists on the given class, it will\r\n be replaced, and a reference to the old method is created as\r\n cls._old<patch_name><name>. If the \"_old_<patch_name>_<name>\" attribute\r\n already exist...
Please provide a description of the function:def get_common_path(pathlist): common = osp.normpath(osp.commonprefix(pathlist)) if len(common) > 1: if not osp.isdir(common): return abspardir(common) else: for path in pathlist: if not osp.isdir(o...
[ "Return common path for all paths in pathlist" ]
Please provide a description of the function:def memoize(obj): cache = obj.cache = {} @functools.wraps(obj) def memoizer(*args, **kwargs): key = str(args) + str(kwargs) if key not in cache: cache[key] = obj(*args, **kwargs) # only keep the most recent 100 e...
[ "\r\n Memoize objects to trade memory for execution speed\r\n\r\n Use a limited size cache to store the value, which takes into account\r\n The calling args and kwargs\r\n\r\n See https://wiki.python.org/moin/PythonDecoratorLibrary#Memoize\r\n " ]
Please provide a description of the function:def regexp_error_msg(pattern): try: re.compile(pattern) except re.error as e: return str(e) return None
[ "\r\n Return None if the pattern is a valid regular expression or\r\n a string describing why the pattern is invalid.\r\n " ]
Please provide a description of the function:def get_range(self, ignore_blank_lines=True): ref_lvl = self.trigger_level first_line = self._trigger.blockNumber() block = self._trigger.next() last_line = block.blockNumber() lvl = self.scope_level if ref_lvl == lvl:...
[ "\n Gets the fold region range (start and end line).\n\n .. note:: Start line do no encompass the trigger line.\n\n :param ignore_blank_lines: True to ignore blank lines at the end of the\n scope (the method will rewind to find that last meaningful block\n that is part of ...
Please provide a description of the function:def fold(self): start, end = self.get_range() TextBlockHelper.set_collapsed(self._trigger, True) block = self._trigger.next() while block.blockNumber() <= end and block.isValid(): block.setVisible(False) block ...
[ "Folds the region." ]
Please provide a description of the function:def unfold(self): # set all direct child blocks which are not triggers to be visible self._trigger.setVisible(True) TextBlockHelper.set_collapsed(self._trigger, False) for block in self.blocks(ignore_blank_lines=False): bl...
[ "Unfolds the region." ]
Please provide a description of the function:def blocks(self, ignore_blank_lines=True): start, end = self.get_range(ignore_blank_lines=ignore_blank_lines) block = self._trigger.next() while block.blockNumber() <= end and block.isValid(): yield block block = block...
[ "\n This generator generates the list of blocks directly under the fold\n region. This list does not contain blocks from child regions.\n\n :param ignore_blank_lines: True to ignore last blank lines.\n " ]
Please provide a description of the function:def child_regions(self): start, end = self.get_range() block = self._trigger.next() ref_lvl = self.scope_level while block.blockNumber() <= end and block.isValid(): lvl = TextBlockHelper.get_fold_lvl(block) tri...
[ "This generator generates the list of direct child regions." ]
Please provide a description of the function:def parent(self): if TextBlockHelper.get_fold_lvl(self._trigger) > 0 and \ self._trigger.blockNumber(): block = self._trigger.previous() ref_lvl = self.trigger_level - 1 while (block.blockNumber() and ...
[ "\n Return the parent scope.\n\n :return: FoldScope or None\n " ]
Please provide a description of the function:def text(self, max_lines=sys.maxsize): ret_val = [] block = self._trigger.next() _, end = self.get_range() while (block.isValid() and block.blockNumber() <= end and len(ret_val) < max_lines): ret_val.append(...
[ "\n Get the scope text, with a possible maximum number of lines.\n\n :param max_lines: limit the number of lines returned to a maximum.\n :return: str\n " ]
Please provide a description of the function:def detect_fold_level(self, prev_block, block): text = block.text() prev_lvl = TextBlockHelper().get_fold_lvl(prev_block) # round down to previous indentation guide to ensure contiguous block # fold level evolution. indent_len...
[ "\n Detects fold level by looking at the block indentation.\n\n :param prev_block: previous text block\n :param block: current block to highlight\n " ]
Please provide a description of the function:def add(self, extension): logger.debug('adding extension {}'.format(extension.name)) self._extensions[extension.name] = extension extension.on_install(self.editor) return extension
[ "\n Add a extension to the editor.\n\n :param extension: The extension instance to add.\n\n " ]
Please provide a description of the function:def remove(self, name_or_klass): logger.debug('removing extension {}'.format(name_or_klass)) extension = self.get(name_or_klass) extension.on_uninstall() self._extensions.pop(extension.name) return extension
[ "\n Remove a extension from the editor.\n\n :param name_or_klass: The name (or class) of the extension to remove.\n :returns: The removed extension.\n " ]
Please provide a description of the function:def clear(self): while len(self._extensions): key = sorted(list(self._extensions.keys()))[0] self.remove(key)
[ "\n Remove all extensions from the editor.\n\n All extensions are removed fromlist and deleted.\n " ]
Please provide a description of the function:def get(self, name_or_klass): if not isinstance(name_or_klass, str): name_or_klass = name_or_klass.__name__ return self._extensions[name_or_klass]
[ "\n Get a extension by name (or class).\n\n :param name_or_klass: The name or the class of the extension to get\n :type name_or_klass: str or type\n :rtype: spyder.api.mode.EditorExtension\n " ]
Please provide a description of the function:def insert_text_to(cursor, text, fmt): while True: index = text.find(chr(8)) # backspace if index == -1: break cursor.insertText(text[:index], fmt) if cursor.positionInBlock() > 0: cursor.deletePreviousChar() ...
[ "Helper to print text, taking into account backspaces" ]
Please provide a description of the function:def set_color_scheme(self, foreground_color, background_color): if dark_color(foreground_color): self.default_foreground_color = 30 else: self.default_foreground_color = 37 if dark_color(background_color): ...
[ "Set color scheme (foreground and background)." ]
Please provide a description of the function:def set_style(self): if self.current_format is None: assert self.base_format is not None self.current_format = QTextCharFormat(self.base_format) # Foreground color if self.foreground_color is None: qcolor =...
[ "\n Set font style with the following attributes:\n 'foreground_color', 'background_color', 'italic',\n 'bold' and 'underline'\n " ]
Please provide a description of the function:def set_color_scheme(self, foreground_color, background_color): self.ansi_handler.set_color_scheme(foreground_color, background_color) background_color = QColor(background_color) foreground_color = QColor(foreground_color) self.set_...
[ "Set color scheme of the console (foreground and background)." ]
Please provide a description of the function:def insert_text(self, text): # Eventually this maybe should wrap to insert_text_to if # backspace-handling is required self.textCursor().insertText(text, self.default_style.format)
[ "Reimplement TextEditBaseWidget method" ]
Please provide a description of the function:def paste(self): if self.has_selected_text(): self.remove_selected_text() self.insert_text(QApplication.clipboard().text())
[ "Reimplement Qt method" ]
Please provide a description of the function:def append_text_to_shell(self, text, error, prompt): cursor = self.textCursor() cursor.movePosition(QTextCursor.End) if '\r' in text: # replace \r\n with \n text = text.replace('\r\n', '\n') text = text.replace('\r'...
[ "\n Append text to Python shell\n In a way, this method overrides the method 'insert_text' when text is\n inserted at the end of the text widget for a Python shell\n\n Handles error messages and show blue underlined links\n Handles ANSI color sequences\n Handles ANSI FF seq...
Please provide a description of the function:def set_pythonshell_font(self, font=None): if font is None: font = QFont() for style in self.font_styles: style.apply_style(font=font, is_default=style is self.default_style) self.ansi_han...
[ "Python Shell only" ]
Please provide a description of the function:def get_plugin_icon(self): path = osp.join(self.PLUGIN_PATH, self.IMG_PATH) return ima.icon('pylint', icon_path=path)
[ "Return widget icon" ]
Please provide a description of the function:def register_plugin(self): self.pylint.treewidget.sig_edit_goto.connect(self.main.editor.load) self.pylint.redirect_stdio.connect( self.main.redirect_internalshell_stdio) self.main.add_dockwidget(self) pyli...
[ "Register plugin in Spyder's main window" ]
Please provide a description of the function:def run_pylint(self): if (self.get_option('save_before', True) and not self.main.editor.save()): return self.switch_to_plugin() self.analyze(self.main.editor.get_current_filename())
[ "Run pylint code analysis" ]
Please provide a description of the function:def analyze(self, filename): if self.dockwidget and not self.ismaximized: self.dockwidget.setVisible(True) self.dockwidget.setFocus() self.dockwidget.raise_() self.pylint.analyze(filename)
[ "Reimplement analyze method" ]
Please provide a description of the function:def set_font(self, font, option): # Update fonts in all plugins set_font(font, option=option) plugins = self.main.widgetlist + self.main.thirdparty_plugins for plugin in plugins: plugin.update_font()
[ "Set global font used in Spyder." ]
Please provide a description of the function:def update_qt_style_combobox(self): if is_dark_interface(): self.style_combobox.setEnabled(False) else: self.style_combobox.setEnabled(True)
[ "Enable/disable the Qt style combobox." ]
Please provide a description of the function:def update_combobox(self): index = self.current_scheme_index self.schemes_combobox.blockSignals(True) names = self.get_option("names") try: names.pop(names.index(u'Custom')) except ValueError: pass ...
[ "Recreates the combobox contents." ]
Please provide a description of the function:def update_buttons(self): current_scheme = self.current_scheme names = self.get_option("names") try: names.pop(names.index(u'Custom')) except ValueError: pass delete_enabled = current_scheme not in name...
[ "Updates the enable status of delete and reset buttons." ]
Please provide a description of the function:def update_preview(self, index=None, scheme_name=None): text = ('\n\n' '# A comment\n\n' '# %% A cell\n\n' 'class Foo(object):\n' ' def __init__(self):\n' ' bar = 42\n'...
[ "\n Update the color scheme of the preview editor and adds text.\n\n Note\n ----\n 'index' is needed, because this is triggered by a signal that sends\n the selected index.\n ", "A string" ]
Please provide a description of the function:def create_new_scheme(self): names = self.get_option('names') custom_names = self.get_option('custom_names', []) # Get the available number this new color scheme counter = len(custom_names) - 1 custom_index = [int(n.split('-'...
[ "Creates a new color scheme with a custom name." ]
Please provide a description of the function:def edit_scheme(self): dlg = self.scheme_editor_dialog dlg.set_scheme(self.current_scheme) if dlg.exec_(): # Update temp scheme to reflect instant edits on the preview temporal_color_scheme = dlg.get_edited_color_sche...
[ "Edit current scheme." ]
Please provide a description of the function:def delete_scheme(self): scheme_name = self.current_scheme answer = QMessageBox.warning(self, _("Warning"), _("Are you sure you want to delete " "this scheme?"), ...
[ "Deletes the currently selected custom color scheme." ]
Please provide a description of the function:def reset_to_default(self): # Checks that this is indeed a default scheme scheme = self.current_scheme names = self.get_option('names') if scheme in names: for key in syntaxhighlighters.COLOR_SCHEME_KEYS: o...
[ "Restore initial values for default color schemes." ]
Please provide a description of the function:def set_scheme(self, scheme_name): self.stack.setCurrentIndex(self.order.index(scheme_name)) self.last_used_scheme = scheme_name
[ "Set the current stack by 'scheme_name'." ]
Please provide a description of the function:def get_edited_color_scheme(self): color_scheme = {} scheme_name = self.last_used_scheme for key in self.widgets[scheme_name]: items = self.widgets[scheme_name][key] if len(items) == 1: # ColorLayout ...
[ "\n Get the values of the last edited color scheme to be used in an instant\n preview in the preview editor, without using `apply`.\n " ]