text stringlengths 81 112k |
|---|
Qt Override.
def focusInEvent(self, e):
"""Qt Override."""
super(ShortcutsTable, self).focusInEvent(e)
self.selectRow(self.currentIndex().row()) |
Adjust column size based on contents.
def adjust_cells(self):
"""Adjust column size based on contents."""
self.resizeColumnsToContents()
fm = self.horizontalHeader().fontMetrics()
names = [fm.width(s.name + ' '*9) for s in self.source_model.shortcuts]
self.setColumnWidth(NA... |
Load shortcuts and assign to table model.
def load_shortcuts(self):
"""Load shortcuts and assign to table model."""
shortcuts = []
for context, name, keystr in iter_shortcuts():
shortcut = Shortcut(context, name, keystr)
shortcuts.append(shortcut)
shortcuts... |
Check shortcuts for conflicts.
def check_shortcuts(self):
"""Check shortcuts for conflicts."""
conflicts = []
for index, sh1 in enumerate(self.source_model.shortcuts):
if index == len(self.source_model.shortcuts)-1:
break
if str(sh1.key) == '':
... |
Save shortcuts from table model.
def save_shortcuts(self):
"""Save shortcuts from table model."""
self.check_shortcuts()
for shortcut in self.source_model.shortcuts:
shortcut.save() |
Create, setup and display the shortcut editor dialog.
def show_editor(self):
"""Create, setup and display the shortcut editor dialog."""
index = self.proxy_model.mapToSource(self.currentIndex())
row, column = index.row(), index.column()
shortcuts = self.source_model.shortcuts
... |
Update the regex text for the shortcut finder.
def set_regex(self, regex=None, reset=False):
"""Update the regex text for the shortcut finder."""
if reset:
text = ''
else:
text = self.finder.text().replace(' ', '').lower()
self.proxy_model.set_filter(text... |
Move to next row from currently selected row.
def next_row(self):
"""Move to next row from currently selected row."""
row = self.currentIndex().row()
rows = self.proxy_model.rowCount()
if row + 1 == rows:
row = -1
self.selectRow(row + 1) |
Move to previous row from currently selected row.
def previous_row(self):
"""Move to previous row from currently selected row."""
row = self.currentIndex().row()
rows = self.proxy_model.rowCount()
if row == 0:
row = rows
self.selectRow(row - 1) |
Qt Override.
def keyPressEvent(self, event):
"""Qt Override."""
key = event.key()
if key in [Qt.Key_Enter, Qt.Key_Return]:
self.show_editor()
elif key in [Qt.Key_Tab]:
self.finder.setFocus()
elif key in [Qt.Key_Backtab]:
self.parent().... |
Reset to default values of the shortcuts making a confirmation.
def reset_to_default(self):
"""Reset to default values of the shortcuts making a confirmation."""
reset = QMessageBox.warning(self, _("Shortcuts reset"),
_("Do you want to reset "
... |
Get a color scheme from config using its name
def get_color_scheme(name):
"""Get a color scheme from config using its name"""
name = name.lower()
scheme = {}
for key in COLOR_SCHEME_KEYS:
try:
scheme[key] = CONF.get('appearance', name+'/'+key)
except:
sch... |
Strongly inspired from idlelib.ColorDelegator.make_pat
def make_python_patterns(additional_keywords=[], additional_builtins=[]):
"Strongly inspired from idlelib.ColorDelegator.make_pat"
kwlist = keyword.kwlist + additional_keywords
builtinlist = [str(name) for name in dir(builtins)
i... |
Returns a code cell name from a code cell comment.
def get_code_cell_name(text):
"""Returns a code cell name from a code cell comment."""
name = text.strip().lstrip("#% ")
if name.startswith("<codecell>"):
name = name[10:].lstrip()
elif name.startswith("In["):
name = name[2:]
... |
Strongly inspired from idlelib.ColorDelegator.make_pat
def make_generic_c_patterns(keywords, builtins,
instance=None, define=None, comment=None):
"Strongly inspired from idlelib.ColorDelegator.make_pat"
kw = r"\b" + any("keyword", keywords.split()) + r"\b"
builtin = r"\b" + ... |
Strongly inspired from idlelib.ColorDelegator.make_pat
def make_fortran_patterns():
"Strongly inspired from idlelib.ColorDelegator.make_pat"
kwstr = 'access action advance allocatable allocate apostrophe assign assignment associate asynchronous backspace bind blank blockdata call case character class close c... |
Strongly inspired from idlelib.ColorDelegator.make_pat
def make_nsis_patterns():
"Strongly inspired from idlelib.ColorDelegator.make_pat"
kwstr1 = 'Abort AddBrandingImage AddSize AllowRootDirInstall AllowSkipFiles AutoCloseWindow BGFont BGGradient BrandingText BringToFront Call CallInstDLL Caption ClearError... |
Strongly inspired from idlelib.ColorDelegator.make_pat
def make_gettext_patterns():
"Strongly inspired from idlelib.ColorDelegator.make_pat"
kwstr = 'msgid msgstr'
kw = r"\b" + any("keyword", kwstr.split()) + r"\b"
fuzzy = any("builtin", [r"#,[^\n]*"])
links = any("normal", [r"#:[^\n]*"])
... |
Strongly inspired from sublime highlighter
def make_yaml_patterns():
"Strongly inspired from sublime highlighter "
kw = any("keyword", [r":|>|-|\||\[|\]|[A-Za-z][\w\s\-\_ ]+(?=:)"])
links = any("normal", [r"#:[^\n]*"])
comment = any("comment", [r"#[^\n]*"])
number = any("number",
... |
Strongly inspired from idlelib.ColorDelegator.make_pat
def make_html_patterns():
"""Strongly inspired from idlelib.ColorDelegator.make_pat """
tags = any("builtin", [r"<", r"[\?/]?>", r"(?<=<).*?(?=[ >])"])
keywords = any("keyword", [r" [\w:-]*?(?==)"])
string = any("string", [r'".*?"'])
comme... |
Factory to generate syntax highlighter for the given filename.
If a syntax highlighter is not available for a particular file, this
function will attempt to generate one based on the lexers in Pygments. If
Pygments is not available or does not have an appropriate lexer, TextSH
will be returned in... |
Highlights a block of text. Please do not override, this method.
Instead you should implement
:func:`spyder.utils.syntaxhighplighters.SyntaxHighlighter.highlight_block`.
:param text: text to highlight.
def highlightBlock(self, text):
"""
Highlights a block of text. Please... |
Make blank space less apparent by setting the foreground alpha.
This only has an effect when 'Show blank space' is turned on.
Derived classes could call this function at the end of
highlightBlock().
def highlight_spaces(self, text, offset=0):
"""
Make blank space less appar... |
Implement specific highlight for Python.
def highlight_block(self, text):
"""Implement specific highlight for Python."""
text = to_text_string(text)
prev_state = tbh.get_state(self.currentBlock().previous())
if prev_state == self.INSIDE_DQ3STRING:
offset = -4
... |
Implement highlight specific for C/C++.
def highlight_block(self, text):
"""Implement highlight specific for C/C++."""
text = to_text_string(text)
inside_comment = tbh.get_state(self.currentBlock().previous()) == self.INSIDE_COMMENT
self.setFormat(0, len(text),
... |
Implement highlight specific for Fortran.
def highlight_block(self, text):
"""Implement highlight specific for Fortran."""
text = to_text_string(text)
self.setFormat(0, len(text), self.formats["normal"])
match = self.PROG.search(text)
index = 0
while matc... |
Implement highlight specific for Fortran77.
def highlight_block(self, text):
"""Implement highlight specific for Fortran77."""
text = to_text_string(text)
if text.startswith(("c", "C")):
self.setFormat(0, len(text), self.formats["comment"])
self.highlight_spaces(tex... |
Implement highlight specific Diff/Patch files.
def highlight_block(self, text):
"""Implement highlight specific Diff/Patch files."""
text = to_text_string(text)
if text.startswith("+++"):
self.setFormat(0, len(text), self.formats["keyword"])
elif text.startswith("---"):... |
Implement highlight specific for CSS and HTML.
def highlight_block(self, text):
"""Implement highlight specific for CSS and HTML."""
text = to_text_string(text)
previous_state = tbh.get_state(self.currentBlock().previous())
if previous_state == self.COMMENT:
s... |
Parses the complete text and stores format for each character.
def make_charlist(self):
"""Parses the complete text and stores format for each character."""
def worker_output(worker, output, error):
"""Worker finished callback."""
self._charlist = output
if er... |
Parses the complete text and stores format for each character.
Uses the attached lexer to parse into a list of tokens and Pygments
token types. Then breaks tokens into individual letters, each with a
Spyder token type attached. Stores this list as self._charlist.
It's attached ... |
Actually highlight the block
def highlightBlock(self, text):
""" Actually highlight the block"""
# Note that an undefined blockstate is equal to -1, so the first block
# will have the correct behaviour of starting at 0.
if self._allow_highlight:
start = self.previousBlo... |
Get all submodules of a given module
def get_submodules(mod):
"""Get all submodules of a given module"""
def catch_exceptions(module):
pass
try:
m = __import__(mod)
submodules = [mod]
submods = pkgutil.walk_packages(m.__path__, m.__name__ + '.',
... |
Get all submodules of the main scientific modules and others of our
interest
def get_preferred_submodules():
"""
Get all submodules of the main scientific modules and others of our
interest
"""
# Path to the modules database
modules_path = get_conf_path('db')
# Modules databas... |
Return true if version is stable, i.e. with letters in the final component.
Stable version examples: ``1.2``, ``1.3.4``, ``1.0.5``.
Non-stable version examples: ``1.3.4beta``, ``0.1.0rc1``, ``3.0.0dev0``.
def is_stable_version(version):
"""
Return true if version is stable, i.e. with letters in t... |
Return whether the dev configuration directory should used.
def use_dev_config_dir(use_dev_config_dir=USE_DEV_CONFIG_DIR):
"""Return whether the dev configuration directory should used."""
if use_dev_config_dir is not None:
if use_dev_config_dir.lower() in {'false', '0'}:
use_dev_config... |
Output debug messages to stdout
def debug_print(*message):
"""Output debug messages to stdout"""
warnings.warn("debug_print is deprecated; use the logging module instead.")
if get_debug_level():
ss = STDOUT
if PY3:
# This is needed after restarting and using debug_print
... |
Return user home directory
def get_home_dir():
"""
Return user home directory
"""
try:
# expanduser() returns a raw byte string which needs to be
# decoded with the codec that the OS is using to represent
# file paths.
path = encoding.to_unicode_from_fs(osp.expan... |
Return the path to a temp clean configuration dir, for tests and safe mode.
def get_clean_conf_dir():
"""
Return the path to a temp clean configuration dir, for tests and safe mode.
"""
if sys.platform.startswith("win"):
current_user = ''
else:
current_user = '-' + str(getpas... |
Return absolute path to the config file with the specified filename.
def get_conf_path(filename=None):
"""Return absolute path to the config file with the specified filename."""
# Define conf_dir
if running_under_pytest() or SAFE_MODE:
# Use clean config dir if running tests or the user request... |
Return module *modname* base path
def get_module_path(modname):
"""Return module *modname* base path"""
return osp.abspath(osp.dirname(sys.modules[modname].__file__)) |
Return module *modname* data path
Note: relpath is ignored if module has an attribute named *attr_name*
Handles py2exe/cx_Freeze distributions
def get_module_data_path(modname, relpath=None, attr_name='DATAPATH'):
"""Return module *modname* data path
Note: relpath is ignored if module has an ... |
Return module *modname* source path
If *basename* is specified, return *modname.basename* path where
*modname* is a package containing the module *basename*
*basename* is a filename (not a module name), so it must include the
file extension: .py or .pyw
Handles py2exe/cx_Freeze dis... |
Return image absolute path
def get_image_path(name, default="not_found.png"):
"""Return image absolute path"""
for img_path in IMG_PATH:
full_path = osp.join(img_path, name)
if osp.isfile(full_path):
return osp.abspath(full_path)
if default is not None:
img_path =... |
List available translations for spyder based on the folders found in the
locale folder. This function checks if LANGUAGE_CODES contain the same
information that is found in the 'locale' folder to ensure that when a new
language is added, LANGUAGE_CODES is updated.
def get_available_translations():
... |
If Spyder has a translation available for the locale language, it will
return the version provided by Spyder adjusted for language subdifferences,
otherwise it will return DEFAULT_LANGUAGE.
Example:
1.) Spyder provides ('en', 'de', 'fr', 'es' 'hu' and 'pt_BR'), if the
locale is either 'en_US... |
Load language setting from language config file if it exists, otherwise
try to use the local settings if Spyder provides a translation, or
return the default if no translation provided.
def load_lang_conf():
"""
Load language setting from language config file if it exists, otherwise
try to use... |
Return translation callback for module *modname*
def get_translation(modname, dirname=None):
"""Return translation callback for module *modname*"""
if dirname is None:
dirname = modname
def translate_dumb(x):
"""Dumb function to not use translations."""
if not is_unicode(x):... |
Remove all config files
def reset_config_files():
"""Remove all config files"""
print("*** Reset Spyder settings to defaults ***", file=STDERR)
for fname in SAVED_CONFIG_FILES:
cfg_fname = get_conf_path(fname)
if osp.isfile(cfg_fname) or osp.islink(cfg_fname):
os.remove(cf... |
Register plugin in Spyder's main window
def register_plugin(self):
"""Register plugin in Spyder's main window"""
ipyconsole = self.main.ipyconsole
treewidget = self.fileexplorer.treewidget
self.main.add_dockwidget(self)
self.fileexplorer.sig_open_file.connect(self.main.op... |
Refresh explorer widget
def refresh_plugin(self, new_path=None, force_current=True):
"""Refresh explorer widget"""
self.fileexplorer.treewidget.update_history(new_path)
self.fileexplorer.treewidget.refresh(new_path,
force_current=force_current) |
Return True if `obj` is type text string, False if it is anything else,
like an instance of a class that extends the basestring class.
def is_type_text_string(obj):
"""Return True if `obj` is type text string, False if it is anything else,
like an instance of a class that extends the basestring class.""... |
Convert `obj` to binary string (bytes in Python 3, str in Python 2)
def to_binary_string(obj, encoding=None):
"""Convert `obj` to binary string (bytes in Python 3, str in Python 2)"""
if PY2:
# Python 2
if encoding is None:
return str(obj)
else:
return obj... |
Save history to a text file in user home directory
def save_history(self):
"""Save history to a text file in user home directory"""
open(self.LOG_PATH, 'w').write("\n".join( \
[to_text_string(self.pydocbrowser.url_combo.itemText(index))
for index in range(self.pydoc... |
DockWidget visibility has changed
def visibility_changed(self, enable):
"""DockWidget visibility has changed"""
super(SpyderPluginWidget, self).visibility_changed(enable)
if enable and not self.pydocbrowser.is_server_running():
self.pydocbrowser.initialize() |
Return the widget to give focus to when
this plugin's dockwidget is raised on top-level
def get_focus_widget(self):
"""
Return the widget to give focus to when
this plugin's dockwidget is raised on top-level
"""
self.pydocbrowser.url_combo.lineEdit().selectAll()
... |
Perform actions before parent main window is closed
def closing_plugin(self, cancelable=False):
"""Perform actions before parent main window is closed"""
self.save_history()
self.set_option('zoom_factor',
self.pydocbrowser.webview.get_zoom_factor())
return T... |
Synchronize Spyder's path list with PYTHONPATH environment variable
Only apply to: current user, on Windows platforms
def synchronize(self):
"""
Synchronize Spyder's path list with PYTHONPATH environment variable
Only apply to: current user, on Windows platforms
"""
... |
Update path list
def update_list(self):
"""Update path list"""
self.listwidget.clear()
for name in self.pathlist+self.ro_pathlist:
item = QListWidgetItem(name)
item.setIcon(ima.icon('DirClosedIcon'))
if name in self.ro_pathlist:
item.se... |
Refresh widget
def refresh(self, row=None):
"""Refresh widget"""
for widget in self.selection_widgets:
widget.setEnabled(self.listwidget.currentItem() is not None)
not_empty = self.listwidget.count() > 0
if self.sync_button is not None:
self.sync_button.set... |
Catch clicks outside the object and ESC key press.
def eventFilter(self, widget, event):
"""Catch clicks outside the object and ESC key press."""
if ((event.type() == QEvent.MouseButtonPress and
not self.geometry().contains(event.globalPos())) or
(event.type() == QE... |
Activate the edit tab.
def edit_tab(self, index):
"""Activate the edit tab."""
# Sets focus, shows cursor
self.setFocus(True)
# Updates tab index
self.tab_index = index
# Gets tab size and shrinks to avoid overlapping tab borders
rect = self.main.tab... |
On clean exit, update tab name.
def edit_finished(self):
"""On clean exit, update tab name."""
# Hides editor
self.hide()
if isinstance(self.tab_index, int) and self.tab_index >= 0:
# We are editing a valid tab, update name
tab_text = to_text_string(self.... |
Reimplement Qt method
def mousePressEvent(self, event):
"""Reimplement Qt method"""
if event.button() == Qt.LeftButton:
self.__drag_start_pos = QPoint(event.pos())
QTabBar.mousePressEvent(self, event) |
Override Qt method
def dragEnterEvent(self, event):
"""Override Qt method"""
mimeData = event.mimeData()
formats = list(mimeData.formats())
if "parent-id" in formats and \
int(mimeData.data("parent-id")) == id(self.ancestor):
event.acceptProposedAction()
... |
Override Qt method
def dropEvent(self, event):
"""Override Qt method"""
mimeData = event.mimeData()
index_from = int(mimeData.data("source-index"))
index_to = self.tabAt(event.pos())
if index_to == -1:
index_to = self.count()
if int(mimeData.data("tabb... |
Override Qt method to trigger the tab name editor.
def mouseDoubleClickEvent(self, event):
"""Override Qt method to trigger the tab name editor."""
if self.rename_tabs is True and \
event.buttons() == Qt.MouseButtons(Qt.LeftButton):
# Tab index
index = self.... |
Update browse tabs menu
def update_browse_tabs_menu(self):
"""Update browse tabs menu"""
self.browse_tabs_menu.clear()
names = []
dirnames = []
for index in range(self.count()):
if self.menu_use_tooltips:
text = to_text_string(self.tabToolTip(i... |
Set tabs corner widgets
corner_widgets: dictionary of (corner, widgets)
corner: Qt.TopLeftCorner or Qt.TopRightCorner
widgets: list of widgets (may contains integers to add spacings)
def set_corner_widgets(self, corner_widgets):
"""
Set tabs corner widgets
corner_w... |
Override Qt method
def contextMenuEvent(self, event):
"""Override Qt method"""
self.setCurrentIndex(self.tabBar().tabAt(event.pos()))
if self.menu:
self.menu.popup(event.globalPos()) |
Override Qt method
def mousePressEvent(self, event):
"""Override Qt method"""
if event.button() == Qt.MidButton:
index = self.tabBar().tabAt(event.pos())
if index >= 0:
self.sig_close_tab.emit(index)
event.accept()
return
... |
Override Qt method
def keyPressEvent(self, event):
"""Override Qt method"""
ctrl = event.modifiers() & Qt.ControlModifier
key = event.key()
handled = False
if ctrl and self.count() > 0:
index = self.currentIndex()
if key == Qt.Key_PageUp:
... |
Ctrl+Tab
def tab_navigate(self, delta=1):
"""Ctrl+Tab"""
if delta > 0 and self.currentIndex() == self.count()-1:
index = delta-1
elif delta < 0 and self.currentIndex() == 0:
index = self.count()+delta
else:
index = self.currentIndex()+delta
... |
Setting Tabs close function
None -> tabs are not closable
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:
# Assumi... |
Move tab inside a tabwidget
def move_tab(self, index_from, index_to):
"""Move tab inside a tabwidget"""
self.move_data.emit(index_from, index_to)
tip, text = self.tabToolTip(index_from), self.tabText(index_from)
icon, widget = self.tabIcon(index_from), self.widget(index_from)
... |
Move tab from a tabwidget to another
def move_tab_from_another_tabwidget(self, tabwidget_from,
index_from, index_to):
"""Move tab from a tabwidget to another"""
# We pass self object IDs as QString objs, because otherwise it would
# dep... |
Return script *fname* run configuration
def get_run_configuration(fname):
"""Return script *fname* run configuration"""
configurations = _get_run_configurations()
for filename, options in configurations:
if fname == filename:
runconf = RunConfiguration()
runconf.set(op... |
Select directory
def select_directory(self):
"""Select directory"""
basedir = to_text_string(self.wd_edit.text())
if not osp.isdir(basedir):
basedir = getcwd_or_home()
directory = getexistingdirectory(self, _("Select directory"), basedir)
if directory:
... |
Add widgets/spacing to dialog vertical layout
def add_widgets(self, *widgets_or_spacings):
"""Add widgets/spacing to dialog vertical layout"""
layout = self.layout()
for widget_or_spacing in widgets_or_spacings:
if isinstance(widget_or_spacing, int):
layout.addS... |
Create dialog button box and add it to the dialog layout
def add_button_box(self, stdbtns):
"""Create dialog button box and add it to the dialog layout"""
bbox = QDialogButtonBox(stdbtns)
run_btn = bbox.addButton(_("Run"), QDialogButtonBox.AcceptRole)
run_btn.clicked.connect(self.ru... |
Setup Run Configuration dialog with filename *fname*
def setup(self, fname):
"""Setup Run Configuration dialog with filename *fname*"""
self.filename = fname
self.runconfigoptions = RunConfigOptions(self)
self.runconfigoptions.set(RunConfiguration(fname).get())
self.add_wid... |
Reimplement Qt method
def accept(self):
"""Reimplement Qt method"""
if not self.runconfigoptions.is_valid():
return
configurations = _get_run_configurations()
configurations.insert(0, (self.filename, self.runconfigoptions.get()))
_set_run_configurations(configu... |
Setup Run Configuration dialog with filename *fname*
def setup(self, fname):
"""Setup Run Configuration dialog with filename *fname*"""
combo_label = QLabel(_("Select a run configuration:"))
self.combo = QComboBox()
self.combo.setMaxVisibleItems(20)
self.combo.setSizeAdjust... |
Reimplement Qt method
def accept(self):
"""Reimplement Qt method"""
configurations = []
for index in range(self.stack.count()):
filename = to_text_string(self.combo.itemText(index))
runconfigoptions = self.stack.widget(index)
if index == self.stack.curr... |
Override Qt method.
Painting line number area
def paintEvent(self, event):
"""Override Qt method.
Painting line number area
"""
painter = QPainter(self)
painter.fillRect(event.rect(), self.editor.sideareas_color)
# This is needed to make that the font size of l... |
Override Qt method.
Show code analisis, if left button pressed select lines.
def mouseMoveEvent(self, event):
"""Override Qt method.
Show code analisis, if left button pressed select lines.
"""
line_number = self.editor.get_linenumber_from_mouse_event(event)
block = se... |
Override Qt method
Select line, and starts selection
def mousePressEvent(self, event):
"""Override Qt method
Select line, and starts selection
"""
line_number = self.editor.get_linenumber_from_mouse_event(event)
self._pressed = line_number
self._released = line... |
Compute and return line number area width
def compute_width(self):
"""Compute and return line number area width"""
if not self._enabled:
return 0
digits = 1
maxb = max(1, self.editor.blockCount())
while maxb >= 10:
maxb /= 10
digits += 1
... |
Setup margin settings
(except font, now set in editor.set_font)
def setup_margins(self, linenumbers=True, markers=True):
"""
Setup margin settings
(except font, now set in editor.set_font)
"""
self._margin = linenumbers
self._markers_margin = markers
self... |
Returns a list with line number, definition name, fold and token.
def process_python_symbol_data(oedata):
"""Returns a list with line number, definition name, fold and token."""
symbol_list = []
for key in oedata:
val = oedata[key]
if val and key != 'found_cell_separators':
if v... |
Return a list of icons for oedata of a python file.
def get_python_symbol_icons(oedata):
"""Return a list of icons for oedata of a python file."""
class_icon = ima.icon('class')
method_icon = ima.icon('method')
function_icon = ima.icon('function')
private_icon = ima.icon('private1')
super_priva... |
Takes a list of paths and tries to "intelligently" shorten them all. The
aim is to make it clear to the user where the paths differ, as that is
likely what they care about. Note that this operates on a list of paths
not on individual paths.
If the path ends in an actual file name, it will be trimmed of... |
Detect when the focus goes out of this widget.
This is used to make the file switcher leave focus on the
last selected file by the user.
def focusOutEvent(self, event):
"""
Detect when the focus goes out of this widget.
This is used to make the file switcher leave focus on the... |
Save initial cursors and initial active widget.
def save_initial_state(self):
"""Save initial cursors and initial active widget."""
paths = self.paths
self.initial_widget = self.get_widget()
self.initial_cursors = {}
for i, editor in enumerate(self.widgets):
if edit... |
Restores initial cursors and initial active editor.
def restore_initial_state(self):
"""Restores initial cursors and initial active editor."""
self.list.clear()
self.is_visible = False
widgets = self.widgets_by_path
if not self.edit.clicked_outside:
for path in self... |
Positions the file switcher dialog.
def set_dialog_position(self):
"""Positions the file switcher dialog."""
parent = self.parent()
geo = parent.geometry()
width = self.list.width() # This has been set in setup
left = parent.geometry().width()/2 - width/2
# Note: the +1... |
Get the max size (width and height) for the elements of a list of
strings as a QLabel.
def get_item_size(self, content):
"""
Get the max size (width and height) for the elements of a list of
strings as a QLabel.
"""
strings = []
if content:
for rich_t... |
Adjusts the width and height of the file switcher
based on the relative size of the parent and content.
def fix_size(self, content):
"""
Adjusts the width and height of the file switcher
based on the relative size of the parent and content.
"""
# Update size of dialog ba... |
Select row in list widget based on a number of steps with direction.
Steps can be positive (next rows) or negative (previous rows).
def select_row(self, steps):
"""Select row in list widget based on a number of steps with direction.
Steps can be positive (next rows) or negative (previous rows... |
Select previous row in list widget.
def previous_row(self):
"""Select previous row in list widget."""
if self.mode == self.SYMBOL_MODE:
self.select_row(-1)
return
prev_row = self.current_row() - 1
if prev_row >= 0:
title = self.list.item(prev_row).tex... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.