Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def is_collapsed(block):
if block is None:
return False
state = block.userState()
if state == -1:
state = 0
return bool(state & 0x08000000) | [
"\n Checks if the block is expanded or collased.\n\n :param block: QTextBlock\n :return: False for an open trigger, True for for closed trigger\n "
] |
Please provide a description of the function:def set_collapsed(block, val):
if block is None:
return
state = block.userState()
if state == -1:
state = 0
state &= 0x77FFFFFF
state |= int(val) << 27
block.setUserState(state) | [
"\n Sets the fold trigger state (collapsed or expanded).\n\n :param block: The block to modify\n :param val: The new trigger state (True=collapsed, False=expanded)\n "
] |
Please provide a description of the function:def get_starting_chunk(filename, length=1024):
# Ensure we open the file in binary mode
with open(filename, 'rb') as f:
chunk = f.read(length)
return chunk | [
"\n :param filename: File to open and get the first little chunk of.\n :param length: Number of bytes to read, default 1024.\n :returns: Starting chunk of bytes.\n "
] |
Please provide a description of the function:def is_binary_string(bytes_to_check):
# Empty files are considered text files
if not bytes_to_check:
return False
# Now check for a high percentage of ASCII control characters
# Binary if control chars are > 30% of the string
low_chars = by... | [
"\n Uses a simplified version of the Perl detection algorithm,\n based roughly on Eli Bendersky's translation to Python:\n https://eli.thegreenplace.net/2011/10/19/perls-guess-if-file-is-text-or-binary-implemented-in-python/\n\n This is biased slightly more in favour of deeming files as text\n files ... |
Please provide a description of the function:def set_value(self, value):
self.value = value
if self.isVisible():
self.label_value.setText(value) | [
"Set formatted text value."
] |
Please provide a description of the function:def setVisible(self, value):
if self.timer is not None:
if value:
self.timer.start(self._interval)
else:
self.timer.stop()
super(BaseTimerStatus, self).setVisible(value) | [
"Override Qt method to stops timers if widget is not visible."
] |
Please provide a description of the function:def set_interval(self, interval):
self._interval = interval
if self.timer is not None:
self.timer.setInterval(interval) | [
"Set timer interval (ms)."
] |
Please provide a description of the function:def get_value(self):
from spyder.utils.system import memory_usage
text = '%d%%' % memory_usage()
return 'Mem ' + text.rjust(3) | [
"Return memory usage."
] |
Please provide a description of the function:def warning(message, css_path=CSS_PATH):
env = Environment()
env.loader = FileSystemLoader(osp.join(CONFDIR_PATH, 'templates'))
warning = env.get_template("warning.html")
return warning.render(css_path=css_path, text=message) | [
"Print a warning message on the rich text view"
] |
Please provide a description of the function:def usage(title, message, tutorial_message, tutorial, css_path=CSS_PATH):
env = Environment()
env.loader = FileSystemLoader(osp.join(CONFDIR_PATH, 'templates'))
usage = env.get_template("usage.html")
return usage.render(css_path=css_path, title=title, in... | [
"Print a usage message on the rich text view"
] |
Please provide a description of the function:def generate_context(name='', argspec='', note='', math=False, collapse=False,
img_path='', css_path=CSS_PATH):
if img_path and os.name == 'nt':
img_path = img_path.replace('\\', '/')
context = \
{
# Arg dependent variabl... | [
"\n Generate the html_context dictionary for our Sphinx conf file.\n \n This is a set of variables to be passed to the Jinja template engine and\n that are used to control how the webpage is rendered in connection with\n Sphinx\n\n Parameters\n ----------\n name : str\n Object's name.... |
Please provide a description of the function:def sphinxify(docstring, context, buildername='html'):
srcdir = mkdtemp()
srcdir = encoding.to_unicode_from_fs(srcdir)
destdir = osp.join(srcdir, '_build')
rst_name = osp.join(srcdir, 'docstring.rst')
if buildername == 'html':
suffix = '.ht... | [
"\n Runs Sphinx on a docstring and outputs the processed documentation.\n\n Parameters\n ----------\n docstring : str\n a ReST-formatted docstring\n\n context : dict\n Variables to be passed to the layout template to control how its\n rendered (through the Sphinx variable *html_c... |
Please provide a description of the function:def generate_configuration(directory):
# conf.py file for Sphinx
conf = osp.join(get_module_source_path('spyder.plugins.help.utils'),
'conf.py')
# Docstring layout page (in Jinja):
layout = osp.join(osp.join(CONFDIR_PATH, 'templ... | [
"\n Generates a Sphinx configuration in `directory`.\n\n Parameters\n ----------\n directory : str\n Base directory to use\n "
] |
Please provide a description of the function:def update_eol(self, os_name):
os_name = to_text_string(os_name)
value = {"nt": "CRLF", "posix": "LF"}.get(os_name, "CR")
self.set_value(value) | [
"Update end of line status."
] |
Please provide a description of the function:def update_encoding(self, encoding):
value = str(encoding).upper()
self.set_value(value) | [
"Update encoding of current file."
] |
Please provide a description of the function:def update_cursor_position(self, line, index):
value = 'Line {}, Col {}'.format(line + 1, index + 1)
self.set_value(value) | [
"Update cursor position."
] |
Please provide a description of the function:def update_vcs(self, fname, index):
fpath = os.path.dirname(fname)
branches, branch, files_modified = get_git_refs(fpath)
text = branch if branch else ''
if len(files_modified):
text = text + ' [{}]'.format(len(files_modi... | [
"Update vcs status."
] |
Please provide a description of the function:def get_settings(self):
settings = {}
for name in REMOTE_SETTINGS:
settings[name] = self.get_option(name)
# dataframe_format is stored without percent sign in config
# to avoid interference with ConfigParser's inte... | [
"\r\n Retrieve all Variable Explorer configuration settings.\r\n \r\n Specifically, return the settings in CONF_SECTION with keys in \r\n REMOTE_SETTINGS, and the setting 'dataframe_format'.\r\n \r\n Returns:\r\n dict: settings\r\n "
] |
Please provide a description of the function:def change_option(self, option_name, new_value):
if option_name == 'dataframe_format':
assert new_value.startswith('%')
new_value = new_value[1:]
self.sig_option_changed.emit(option_name, new_value) | [
"\r\n Change a config option.\r\n\r\n This function is called if sig_option_changed is received. If the\r\n option changed is the dataframe format, then the leading '%' character\r\n is stripped (because it can't be stored in the user config). Then,\r\n the signal is emitted again... |
Please provide a description of the function:def free_memory(self):
self.main.free_memory()
QTimer.singleShot(self.INITIAL_FREE_MEMORY_TIME_TRIGGER,
lambda: self.main.free_memory())
QTimer.singleShot(self.SECONDARY_FREE_MEMORY_TIME_TRIGGER,
... | [
"Free memory signal."
] |
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)
nsb = NamespaceBrowser(self, options_button=self.options_button)
... | [
"\r\n Register shell with variable explorer.\r\n\r\n This function opens a new NamespaceBrowser for browsing the variables\r\n in the shell.\r\n "
] |
Please provide a description of the function:def import_data(self, fname):
if self.count():
nsb = self.current_widget()
nsb.refresh_table()
nsb.import_data(filenames=fname)
if self.dockwidget and not self.ismaximized:
self.dockwidge... | [
"Import data in current namespace"
] |
Please provide a description of the function:def is_valid(self, qstr=None):
if not self.help.source_is_console():
return True
if qstr is None:
qstr = self.currentText()
if not re.search(r'^[a-zA-Z0-9_\.]*$', str(qstr), 0):
return False
objtxt ... | [
"Return True if string is valid"
] |
Please provide a description of the function:def validate(self, qstr, editing=True):
valid = self.is_valid(qstr)
if self.hasFocus() and valid is not None:
if editing and not valid:
# Combo box text is being modified: invalidate the entry
self.show_tip... | [
"Reimplemented to avoid formatting actions"
] |
Please provide a description of the function:def set_font(self, font, fixed_font=None):
self.webview.set_font(font, fixed_font=fixed_font) | [
"Set font"
] |
Please provide a description of the function:def set_font(self, font, color_scheme=None):
self.editor.set_font(font, color_scheme=color_scheme) | [
"Set font"
] |
Please provide a description of the function:def find_tasks(source_code):
results = []
for line, text in enumerate(source_code.splitlines()):
for todo in re.findall(TASKS_PATTERN, text):
todo_text = (todo[-1].strip(' :').capitalize() if todo[-1]
else todo[... | [
"Find tasks in source code (TODO, FIXME, XXX, ...)"
] |
Please provide a description of the function:def check_with_pyflakes(source_code, filename=None):
try:
if filename is None:
filename = '<string>'
try:
source_code += '\n'
except TypeError:
# Python 3
source_code += to_binary_strin... | [
"Check source code with pyflakes\r\n Returns an empty list if pyflakes is not installed"
] |
Please provide a description of the function:def get_checker_executable(name):
if programs.is_program_installed(name):
# Checker is properly installed
return [name]
else:
path1 = programs.python_script_exists(package=None,
module=... | [
"Return checker executable in the form of a list of arguments\r\n for subprocess.Popen"
] |
Please provide a description of the function:def check(args, source_code, filename=None, options=None):
if args is None:
return []
if options is not None:
args += options
if any(['pyflakes' in arg for arg in args]):
# Pyflakes requires an ending new line (pycodestyle don... | [
"Check source code with checker defined with *args* (list)\r\n Returns an empty list if checker is not installed"
] |
Please provide a description of the function:def check_with_pep8(source_code, filename=None):
try:
args = get_checker_executable('pycodestyle')
results = check(args, source_code, filename=filename, options=['-r'])
except Exception:
# Never return None to avoid lock in spyder/w... | [
"Check source code with pycodestyle"
] |
Please provide a description of the function:def get_image_label(name, default="not_found.png"):
label = QLabel()
label.setPixmap(QPixmap(get_image_path(name, default)))
return label | [
"Return image inside a QLabel object"
] |
Please provide a description of the function:def qapplication(translate=True, test_time=3):
if running_in_mac_app():
SpyderApplication = MacApplication
else:
SpyderApplication = QApplication
app = SpyderApplication.instance()
if app is None:
# Set Application n... | [
"\r\n Return QApplication instance\r\n Creates it if it doesn't already exist\r\n \r\n test_time: Time to maintain open the application when testing. It's given\r\n in seconds\r\n "
] |
Please provide a description of the function:def file_uri(fname):
if os.name == 'nt':
# Local file
if re.search(r'^[a-zA-Z]:', fname):
return 'file:///' + fname
# UNC based path
else:
return 'file://' + fname
else:
return 'file://' +... | [
"Select the right file uri scheme according to the operating system"
] |
Please provide a description of the function:def install_translator(qapp):
global QT_TRANSLATOR
if QT_TRANSLATOR is None:
qt_translator = QTranslator()
if qt_translator.load("qt_"+QLocale.system().name(),
QLibraryInfo.location(QLibraryInfo.TranslationsPath)):
... | [
"Install Qt translator to the QApplication instance"
] |
Please provide a description of the function:def keybinding(attr):
ks = getattr(QKeySequence, attr)
return from_qvariant(QKeySequence.keyBindings(ks)[0], str) | [
"Return keybinding"
] |
Please provide a description of the function:def mimedata2url(source, extlist=None):
pathlist = []
if source.hasUrls():
for url in source.urls():
path = _process_mime_path(to_text_string(url.toString()), extlist)
if path is not None:
pathlist.append(pa... | [
"\r\n Extract url list from MIME data\r\n extlist: for example ('.py', '.pyw')\r\n "
] |
Please provide a description of the function:def keyevent2tuple(event):
return (event.type(), event.key(), event.modifiers(), event.text(),
event.isAutoRepeat(), event.count()) | [
"Convert QKeyEvent instance into a tuple"
] |
Please provide a description of the function:def create_toolbutton(parent, text=None, shortcut=None, icon=None, tip=None,
toggled=None, triggered=None,
autoraise=True, text_beside_icon=False):
button = QToolButton(parent)
if text is not None:
button... | [
"Create a QToolButton"
] |
Please provide a description of the function:def action2button(action, autoraise=True, text_beside_icon=False, parent=None):
if parent is None:
parent = action.parent()
button = QToolButton(parent)
button.setDefaultAction(action)
button.setAutoRaise(autoraise)
if text_beside_icon... | [
"Create a QToolButton directly from a QAction object"
] |
Please provide a description of the function:def toggle_actions(actions, enable):
if actions is not None:
for action in actions:
if action is not None:
action.setEnabled(enable) | [
"Enable/disable actions"
] |
Please provide a description of the function:def create_action(parent, text, shortcut=None, icon=None, tip=None,
toggled=None, triggered=None, data=None, menurole=None,
context=Qt.WindowShortcut):
action = SpyderAction(text, parent)
if triggered is not None:
... | [
"Create a QAction"
] |
Please provide a description of the function:def add_shortcut_to_tooltip(action, context, name):
action.setToolTip(action.toolTip() + ' (%s)' %
get_shortcut(context=context, name=name)) | [
"Add the shortcut associated with a given action to its tooltip"
] |
Please provide a description of the function:def add_actions(target, actions, insert_before=None):
previous_action = None
target_actions = list(target.actions())
if target_actions:
previous_action = target_actions[-1]
if previous_action.isSeparator():
previous_action ... | [
"Add actions to a QMenu or a QToolBar."
] |
Please provide a description of the function:def create_bookmark_action(parent, url, title, icon=None, shortcut=None):
@Slot()
def open_url():
return programs.start_file(url)
return create_action( parent, title, shortcut=shortcut, icon=icon,
triggered... | [
"Create bookmark action"
] |
Please provide a description of the function:def create_module_bookmark_actions(parent, bookmarks):
actions = []
for key, url, title in bookmarks:
# Create actions for scientific distros only if Spyder is installed
# under them
create_act = True
if key == 'winpython':... | [
"\r\n Create bookmark actions depending on module installation:\r\n bookmarks = ((module_name, url, title), ...)\r\n "
] |
Please provide a description of the function:def create_program_action(parent, text, name, icon=None, nt_name=None):
if is_text_string(icon):
icon = get_icon(icon)
if os.name == 'nt' and nt_name is not None:
name = nt_name
path = programs.find_program(name)
if path is not Non... | [
"Create action to run a program"
] |
Please provide a description of the function:def create_python_script_action(parent, text, icon, package, module, args=[]):
if is_text_string(icon):
icon = get_icon(icon)
if programs.python_script_exists(package, module):
return create_action(parent, text, icon=icon,
... | [
"Create action to run a GUI based Python script"
] |
Please provide a description of the function:def get_filetype_icon(fname):
ext = osp.splitext(fname)[1]
if ext.startswith('.'):
ext = ext[1:]
return get_icon( "%s.png" % ext, ima.icon('FileIcon') ) | [
"Return file type icon"
] |
Please provide a description of the function:def show_std_icons():
app = qapplication()
dialog = ShowStdIcons(None)
dialog.show()
sys.exit(app.exec_()) | [
"\r\n Show all standard Icons\r\n "
] |
Please provide a description of the function:def calc_tools_spacing(tools_layout):
metrics = { # (tabbar_height, offset)
'nt.fusion': (32, 0),
'nt.windowsvista': (21, 3),
'nt.windowsxp': (24, 0),
'nt.windows': (21, 3),
'posix.breeze': (28, -1),
'posix.ox... | [
"\r\n Return a spacing (int) or None if we don't have the appropriate metrics\r\n to calculate the spacing.\r\n\r\n We're trying to adapt the spacing below the tools_layout spacing so that\r\n the main_widget has the same vertical position as the editor widgets\r\n (which have tabs above).\r\n\r\n ... |
Please provide a description of the function:def create_plugin_layout(tools_layout, main_widget=None):
layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
spacing = calc_tools_spacing(tools_layout)
if spacing is not None:
layout.setSpacing(spacing)
layout.addLayout(too... | [
"\r\n Returns a layout for a set of controls above a main widget. This is a\r\n standard layout for many plugin panes (even though, it's currently\r\n more often applied not to the pane itself but with in the one widget\r\n contained in the pane.\r\n\r\n tools_layout: a layout containing the top tool... |
Please provide a description of the function:def show(self, dialog):
for dlg in list(self.dialogs.values()):
if to_text_string(dlg.windowTitle()) \
== to_text_string(dialog.windowTitle()):
dlg.show()
dlg.raise_()
break
... | [
"Generic method to show a non-modal dialog and keep reference\r\n to the Qt C++ object"
] |
Please provide a description of the function:def add(modname, features, required_version, installed_version=None,
optional=False):
global DEPENDENCIES
for dependency in DEPENDENCIES:
if dependency.modname == modname:
raise ValueError("Dependency has already been registered... | [
"Add Spyder dependency"
] |
Please provide a description of the function:def check(modname):
for dependency in DEPENDENCIES:
if dependency.modname == modname:
return dependency.check()
else:
raise RuntimeError("Unkwown dependency %s" % modname) | [
"Check if required dependency is installed"
] |
Please provide a description of the function:def status(deps=DEPENDENCIES, linesep=os.linesep):
maxwidth = 0
col1 = []
col2 = []
for dependency in deps:
title1 = dependency.modname
title1 += ' ' + dependency.required_version
col1.append(title1)
maxwidth = ma... | [
"Return a status of dependencies"
] |
Please provide a description of the function:def missing_dependencies():
missing_deps = []
for dependency in DEPENDENCIES:
if not dependency.check() and not dependency.optional:
missing_deps.append(dependency)
if missing_deps:
return status(deps=missing_deps, linesep=... | [
"Return the status of missing dependencies (if any)"
] |
Please provide a description of the function:def check(self):
return programs.is_module_installed(self.modname,
self.required_version,
self.installed_version) | [
"Check if dependency is installed"
] |
Please provide a description of the function:def get_installed_version(self):
if self.check():
return '%s (%s)' % (self.installed_version, self.OK)
else:
return '%s (%s)' % (self.installed_version, self.NOK) | [
"Return dependency status (string)"
] |
Please provide a description of the function:def get_spyderplugins_mods(io=False):
# Create user directory
user_plugin_path = osp.join(get_conf_path(), USER_PLUGIN_DIR)
if not osp.isdir(user_plugin_path):
os.makedirs(user_plugin_path)
modlist, modnames = [], []
# The user plu... | [
"Import modules from plugins package and return the list"
] |
Please provide a description of the function:def _get_spyderplugins(plugin_path, is_io, modnames, modlist):
if not osp.isdir(plugin_path):
return
for name in os.listdir(plugin_path):
# This is needed in order to register the spyder_io_hdf5 plugin.
# See issue 4487
#... | [
"Scan the directory `plugin_path` for plugin packages and loads them."
] |
Please provide a description of the function:def _import_plugin(module_name, plugin_path, modnames, modlist):
if module_name in modnames:
return
try:
# First add a mock module with the LOCALEPATH attribute so that the
# helper method can find the locale on import
mock... | [
"Import the plugin `module_name` from `plugin_path`, add it to `modlist`\r\n and adds its name to `modnames`.\r\n "
] |
Please provide a description of the function:def _import_module_from_path(module_name, plugin_path):
module = None
try:
if PY2:
info = imp.find_module(module_name, [plugin_path])
if info:
module = imp.load_module(module_name, *info)
else: # P... | [
"Imports `module_name` from `plugin_path`.\r\n\r\n Return None if no module is found.\r\n "
] |
Please provide a description of the function:def get_std_icon(name, size=None):
if not name.startswith('SP_'):
name = 'SP_' + name
icon = QWidget().style().standardIcon(getattr(QStyle, name))
if size is None:
return icon
else:
return QIcon(icon.pixmap(size, size)) | [
"Get standard platform icon\n Call 'show_std_icons()' for details"
] |
Please provide a description of the function:def get_icon(name, default=None, resample=False):
icon_path = get_image_path(name, default=None)
if icon_path is not None:
icon = QIcon(icon_path)
elif isinstance(default, QIcon):
icon = default
elif default is None:
try:
... | [
"Return image inside a QIcon object.\n\n default: default image name or icon\n resample: if True, manually resample icon pixmaps for usual sizes\n (16, 24, 32, 48, 96, 128, 256). This is recommended for QMainWindow icons\n created from SVG images on non-Windows platforms due to a Qt bug (see\n Issue ... |
Please provide a description of the function:def get_icon_by_extension(fname, scale_factor):
application_icons = {}
application_icons.update(BIN_FILES)
application_icons.update(DOCUMENT_FILES)
if osp.isdir(fname):
return icon('DirOpenIcon', scale_factor)
else:
basename = osp.bas... | [
"Return the icon depending on the file extension"
] |
Please provide a description of the function:def accept(self):
AutosaveErrorDialog.show_errors = not self.dismiss_box.isChecked()
return QDialog.accept(self) | [
"\n Update `show_errors` and hide dialog box.\n\n Overrides method of `QDialogBox`.\n "
] |
Please provide a description of the function:def setup_common_actions(self):
self.collapse_all_action = create_action(self,
text=_('Collapse all'),
icon=ima.icon('collapse'),
triggered=se... | [
"Setup context menu common actions"
] |
Please provide a description of the function:def get_menu_actions(self):
items = self.selectedItems()
actions = self.get_actions_from_items(items)
if actions:
actions.append(None)
actions += self.common_actions
return actions | [
"Returns a list of menu actions"
] |
Please provide a description of the function:def item_selection_changed(self):
is_selection = len(self.selectedItems()) > 0
self.expand_selection_action.setEnabled(is_selection)
self.collapse_selection_action.setEnabled(is_selection) | [
"Item selection has changed"
] |
Please provide a description of the function:def get_items(self):
itemlist = []
def add_to_itemlist(item):
for index in range(item.childCount()):
citem = item.child(index)
itemlist.append(citem)
add_to_itemlist(citem)
f... | [
"Return items (excluding top level items)"
] |
Please provide a description of the function:def save_expanded_state(self):
self.__expanded_state = {}
def add_to_state(item):
user_text = get_item_user_text(item)
self.__expanded_state[hash(user_text)] = item.isExpanded()
def browse_children(item):
... | [
"Save all items expanded state"
] |
Please provide a description of the function:def restore_expanded_state(self):
if self.__expanded_state is None:
return
for item in self.get_items()+self.get_top_level_items():
user_text = get_item_user_text(item)
is_expanded = self.__expanded_state.get... | [
"Restore all items expanded state"
] |
Please provide a description of the function:def sort_top_level_items(self, key):
self.save_expanded_state()
items = sorted([self.takeTopLevelItem(0)
for index in range(self.topLevelItemCount())], key=key)
for index, item in enumerate(items):
se... | [
"Sorting tree wrt top level items"
] |
Please provide a description of the function:def contextMenuEvent(self, event):
self.update_menu()
self.menu.popup(event.globalPos()) | [
"Override Qt method"
] |
Please provide a description of the function:def get_stdlib_modules():
modules = list(sys.builtin_module_names)
for path in sys.path[1:]:
if 'site-packages' not in path:
modules += module_list(path)
modules = set(modules)
if '__init__' in modules:
modules.remove('__... | [
"\n Returns a list containing the names of all the modules available in the\n standard library.\n \n Based on the function get_root_modules from the IPython project.\n Present in IPython.core.completerlib in v0.13.1\n \n Copyright (C) 2010-2011 The IPython Development Team.\n Distributed und... |
Please provide a description of the function:def print_tree(editor, file=sys.stdout, print_blocks=False, return_list=False):
output_list = []
block = editor.document().firstBlock()
while block.isValid():
trigger = TextBlockHelper().is_fold_trigger(block)
trigger_state = TextBlockHelper... | [
"\n Prints the editor fold tree to stdout, for debugging purpose.\n\n :param editor: CodeEditor instance.\n :param file: file handle where the tree will be printed. Default is stdout.\n :param print_blocks: True to print all blocks, False to only print blocks\n that are fold triggers\n "
] |
Please provide a description of the function:def envdict2listdict(envdict):
sep = os.path.pathsep
for key in envdict:
if sep in envdict[key]:
envdict[key] = [path.strip() for path in envdict[key].split(sep)]
return envdict | [
"Dict --> Dict of lists"
] |
Please provide a description of the function:def listdict2envdict(listdict):
for key in listdict:
if isinstance(listdict[key], list):
listdict[key] = os.path.pathsep.join(listdict[key])
return listdict | [
"Dict of lists --> Dict"
] |
Please provide a description of the function:def main():
from spyder.utils.qthelpers import qapplication
app = qapplication()
if os.name == 'nt':
dialog = WinUserEnvDialog()
else:
dialog = EnvDialog()
dialog.show()
app.exec_() | [
"Run Windows environment variable editor"
] |
Please provide a description of the function:def keyPressEvent(self, event):
if event.key() in [Qt.Key_Enter, Qt.Key_Return]:
self._parent.process_text()
if self._parent.is_valid():
self._parent.keyPressEvent(event)
else:
QLineEdit.keyP... | [
"\r\n Qt override.\r\n "
] |
Please provide a description of the function:def event(self, event):
if event.type() == QEvent.KeyPress:
if (event.key() == Qt.Key_Tab or event.key() == Qt.Key_Space):
text = self.text()
cursor = self.cursorPosition()
# fix to include in... | [
"\r\n Qt override.\r\n\r\n This is needed to be able to intercept the Tab key press event.\r\n "
] |
Please provide a description of the function:def keyPressEvent(self, event):
if event.key() in [Qt.Key_Enter, Qt.Key_Return]:
QTableWidget.keyPressEvent(self, event)
# To avoid having to enter one final tab
self.setDisabled(True)
self.setDisabled(Fa... | [
"\r\n Qt override.\r\n "
] |
Please provide a description of the function:def reset_headers(self):
rows = self.rowCount()
cols = self.columnCount()
for r in range(rows):
self.setVerticalHeaderItem(r, QTableWidgetItem(str(r)))
for c in range(cols):
self.setHorizontalHeaderIte... | [
"\r\n Update the column and row numbering in the headers.\r\n "
] |
Please provide a description of the function:def text(self):
text = []
rows = self.rowCount()
cols = self.columnCount()
# handle empty table case
if rows == 2 and cols == 2:
item = self.item(0, 0)
if item is None:
return... | [
"\r\n Return the entered array in a parseable form.\r\n "
] |
Please provide a description of the function:def keyPressEvent(self, event):
QToolTip.hideText()
ctrl = event.modifiers() & Qt.ControlModifier
if event.key() in [Qt.Key_Enter, Qt.Key_Return]:
if ctrl:
self.process_text(array=False)
else:
... | [
"\r\n Qt override.\r\n "
] |
Please provide a description of the function:def event(self, event):
if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Tab:
return False
return QWidget.event(self, event) | [
"\r\n Qt Override.\r\n\r\n Usefull when in line edit mode.\r\n "
] |
Please provide a description of the function:def process_text(self, array=True):
if array:
prefix = 'np.array([['
else:
prefix = 'np.matrix([['
suffix = ']])'
values = self._widget.text().strip()
if values != '':
# cleans ... | [
"\r\n Construct the text based on the entered content in the widget.\r\n "
] |
Please provide a description of the function:def update_warning(self):
widget = self._button_warning
if not self.is_valid():
tip = _('Array dimensions not valid')
widget.setIcon(ima.icon('MessageBoxWarning'))
widget.setToolTip(tip)
QToolTip... | [
"\r\n Updates the icon and tip based on the validity of the array content.\r\n "
] |
Please provide a description of the function:def _save_lang(self):
for combobox, (option, _default) in list(self.comboboxes.items()):
if option == 'interface_language':
data = combobox.itemData(combobox.currentIndex())
value = from_qvariant(data, to_text_stri... | [
"\n Get selected language setting and save to language configuration file.\n "
] |
Please provide a description of the function:def is_writable(path):
try:
testfile = tempfile.TemporaryFile(dir=path)
testfile.close()
except OSError as e:
if e.errno == errno.EACCES: # 13
return False
return True | [
"Check if path has write access"
] |
Please provide a description of the function:def _get_project_types(self):
project_types = get_available_project_types()
projects = []
for project in project_types:
projects.append(project.PROJECT_TYPE_NAME)
return projects | [
"Get all available project types."
] |
Please provide a description of the function:def select_location(self):
location = osp.normpath(getexistingdirectory(self,
_("Select directory"),
self.location))
if location:
... | [
"Select directory."
] |
Please provide a description of the function:def update_location(self, text=''):
self.text_project_name.setEnabled(self.radio_new_dir.isChecked())
name = self.text_project_name.text().strip()
if name and self.radio_new_dir.isChecked():
path = osp.join(self.location, n... | [
"Update text of location."
] |
Please provide a description of the function:def create_project(self):
packages = ['python={0}'.format(self.combo_python_version.currentText())]
self.sig_project_creation_requested.emit(
self.text_location.text(),
self.combo_project_type.currentText(),
... | [
"Create project."
] |
Please provide a description of the function:def set_font(self, font):
self.setFont(font)
self.set_pythonshell_font(font)
cursor = self.textCursor()
cursor.select(QTextCursor.Document)
charformat = QTextCharFormat()
charformat.setFontFamily(font.family())
... | [
"Set shell styles font"
] |
Please provide a description of the function:def setup_context_menu(self):
self.menu = QMenu(self)
self.cut_action = create_action(self, _("Cut"),
shortcut=keybinding('Cut'),
icon=ima.icon('editcut'),
... | [
"Setup shell context menu"
] |
Please provide a description of the function:def contextMenuEvent(self, event):
state = self.has_selected_text()
self.copy_action.setEnabled(state)
self.cut_action.setEnabled(state)
self.delete_action.setEnabled(state)
self.menu.popup(event.globalPos())
ev... | [
"Reimplement Qt method"
] |
Please provide a description of the function:def _select_input(self):
line, index = self.get_position('eof')
if self.current_prompt_pos is None:
pline, pindex = line, index
else:
pline, pindex = self.current_prompt_pos
self.setSelection(pline, pind... | [
"Select current line (without selecting console prompt)"
] |
Please provide a description of the function:def _set_input_buffer(self, text):
if self.current_prompt_pos is not None:
self.replace_text(self.current_prompt_pos, 'eol', text)
else:
self.insert(text)
self.set_cursor_position('eof') | [
"Set input buffer"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.