本文整理汇总了Python中spyderlib.config.main.CONF.get方法的典型用法代码示例。如果您正苦于以下问题:Python CONF.get方法的具体用法?Python CONF.get怎么用?Python CONF.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.config.main.CONF
的用法示例。
在下文中一共展示了CONF.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_font
# 需要导入模块: from spyderlib.config.main import CONF [as 别名]
# 或者: from spyderlib.config.main.CONF import get [as 别名]
def get_font(section='main', option='font', font_size_delta=0):
"""Get console font properties depending on OS and user options"""
font = FONT_CACHE.get((section, option))
if font is None:
families = CONF.get(section, option+"/family", None)
if families is None:
return QFont()
family = get_family(families)
weight = QFont.Normal
italic = CONF.get(section, option+'/italic', False)
if CONF.get(section, option+'/bold', False):
weight = QFont.Bold
size = CONF.get(section, option+'/size', 9) + font_size_delta
font = QFont(family, size, weight)
font.setItalic(italic)
FONT_CACHE[(section, option)] = font
size = CONF.get(section, option+'/size', 9) + font_size_delta
font.setPointSize(size)
return font
示例2: long_banner
# 需要导入模块: from spyderlib.config.main import CONF [as 别名]
# 或者: from spyderlib.config.main.CONF import get [as 别名]
def long_banner(self):
"""Banner for IPython widgets with pylab message"""
from IPython.core.usage import default_gui_banner
banner = default_gui_banner
pylab_o = CONF.get('ipython_console', 'pylab', True)
autoload_pylab_o = CONF.get('ipython_console', 'pylab/autoload', True)
mpl_installed = programs.is_module_installed('matplotlib')
if mpl_installed and (pylab_o and autoload_pylab_o):
pylab_message = ("\nPopulating the interactive namespace from "
"numpy and matplotlib")
banner = banner + pylab_message
sympy_o = CONF.get('ipython_console', 'symbolic_math', True)
if sympy_o:
lines = """
These commands were executed:
>>> from __future__ import division
>>> from sympy import *
>>> x, y, z, t = symbols('x y z t')
>>> k, m, n = symbols('k m n', integer=True)
>>> f, g, h = symbols('f g h', cls=Function)
"""
banner = banner + lines
return banner
示例3: _get_run_configurations
# 需要导入模块: from spyderlib.config.main import CONF [as 别名]
# 或者: from spyderlib.config.main.CONF import get [as 别名]
def _get_run_configurations():
history_count = CONF.get("run", "history", 20)
try:
return [
(filename, options) for filename, options in CONF.get("run", "configurations", []) if osp.isfile(filename)
][:history_count]
except ValueError:
CONF.set("run", "configurations", [])
return []
示例4: update_margins
# 需要导入模块: from spyderlib.config.main import CONF [as 别名]
# 或者: from spyderlib.config.main.CONF import get [as 别名]
def update_margins(self):
layout = self.layout()
if self.default_margins is None:
self.default_margins = layout.getContentsMargins()
if CONF.get('main', 'use_custom_margin'):
margin = CONF.get('main', 'custom_margin')
layout.setContentsMargins(*[margin]*4)
else:
layout.setContentsMargins(*self.default_margins)
示例5: set_color_scheme
# 需要导入模块: from spyderlib.config.main import CONF [as 别名]
# 或者: from spyderlib.config.main.CONF import get [as 别名]
def set_color_scheme(name, color_scheme, replace=True):
"""Set syntax color scheme"""
section = "color_schemes"
names = CONF.get("color_schemes", "names", [])
for key in sh.COLOR_SCHEME_KEYS:
option = "%s/%s" % (name, key)
value = CONF.get(section, option, default=None)
if value is None or replace or name not in names:
CONF.set(section, option, color_scheme[key])
names.append(to_text_string(name))
CONF.set(section, "names", sorted(list(set(names))))
示例6: external_editor
# 需要导入模块: from spyderlib.config.main import CONF [as 别名]
# 或者: from spyderlib.config.main.CONF import get [as 别名]
def external_editor(self, filename, goto=-1):
"""Edit in an external editor
Recommended: SciTE (e.g. to go to line where an error did occur)"""
editor_path = CONF.get("internal_console", "external_editor/path")
goto_option = CONF.get("internal_console", "external_editor/gotoline")
try:
if goto > 0 and goto_option:
Popen(r'%s "%s" %s%d' % (editor_path, filename, goto_option, goto))
else:
Popen(r'%s "%s"' % (editor_path, filename))
except OSError:
self.write_error("External editor was not found:" " %s\n" % editor_path)
示例7: external_editor
# 需要导入模块: from spyderlib.config.main import CONF [as 别名]
# 或者: from spyderlib.config.main.CONF import get [as 别名]
def external_editor(self, filename, goto=-1):
"""Edit in an external editor
Recommended: SciTE (e.g. to go to line where an error did occur)"""
editor_path = CONF.get('internal_console', 'external_editor/path')
goto_option = CONF.get('internal_console', 'external_editor/gotoline')
try:
args = [filename]
if goto > 0 and goto_option:
args.append('%s%d'.format(goto_option, goto))
programs.run_program(editor_path, args)
except OSError:
self.write_error("External editor was not found:"
" %s\n" % editor_path)
示例8: __init__
# 需要导入模块: from spyderlib.config.main import CONF [as 别名]
# 或者: from spyderlib.config.main.CONF import get [as 别名]
def __init__(self, fname=None):
self.args = None
self.args_enabled = None
self.wdir = None
self.wdir_enabled = None
self.current = None
self.systerm = None
self.interact = None
self.show_kill_warning = None
self.post_mortem = None
self.python_args = None
self.python_args_enabled = None
self.set(CONF.get("run", "defaultconfiguration", default={}))
if fname is not None and CONF.get("run", WDIR_USE_SCRIPT_DIR_OPTION, True):
self.wdir = osp.dirname(fname)
self.wdir_enabled = True
示例9: setup_page
# 需要导入模块: from spyderlib.config.main import CONF [as 别名]
# 或者: from spyderlib.config.main.CONF import get [as 别名]
def setup_page(self):
settings_group = QGroupBox(_("Settings"))
hist_spin = self.create_spinbox(
_("History depth: "), _(" entries"),
'max_entries', min_=10, max_=10000, step=10,
tip=_("Set maximum line count"))
sourcecode_group = QGroupBox(_("Source code"))
wrap_mode_box = self.create_checkbox(_("Wrap lines"), 'wrap')
go_to_eof_box = self.create_checkbox(
_("Scroll automatically to last entry"), 'go_to_eof')
font_group = self.create_fontgroup(option=None,
text=_("Font style"),
fontfilters=QFontComboBox.MonospacedFonts)
names = CONF.get('color_schemes', 'names')
choices = list(zip(names, names))
cs_combo = self.create_combobox(_("Syntax color scheme: "),
choices, 'color_scheme_name')
settings_layout = QVBoxLayout()
settings_layout.addWidget(hist_spin)
settings_group.setLayout(settings_layout)
sourcecode_layout = QVBoxLayout()
sourcecode_layout.addWidget(wrap_mode_box)
sourcecode_layout.addWidget(go_to_eof_box)
sourcecode_layout.addWidget(cs_combo)
sourcecode_group.setLayout(sourcecode_layout)
vlayout = QVBoxLayout()
vlayout.addWidget(font_group)
vlayout.addWidget(settings_group)
vlayout.addWidget(sourcecode_group)
vlayout.addStretch(1)
self.setLayout(vlayout)
示例10: __init__
# 需要导入模块: from spyderlib.config.main import CONF [as 别名]
# 或者: from spyderlib.config.main.CONF import get [as 别名]
def __init__(self, main=None, **kwds):
"""Bind widget to a QMainWindow instance"""
super(SpyderPluginMixin, self).__init__(**kwds)
assert self.CONF_SECTION is not None
self.PLUGIN_PATH = os.path.dirname(inspect.getfile(self.__class__))
self.main = main
self.default_margins = None
self.plugin_actions = None
self.dockwidget = None
self.mainwindow = None
self.ismaximized = False
self.isvisible = False
# NOTE: Don't use the default option of CONF.get to assign a
# None shortcut to plugins that don't have one. That will mess
# the creation of our Keyboard Shortcuts prefs page
try:
self.shortcut = CONF.get('shortcuts', '_/switch to %s' % \
self.CONF_SECTION)
except configparser.NoOptionError:
self.shortcut = None
# We decided to create our own toggle action instead of using
# the one that comes with dockwidget because it's not possible
# to raise and focus the plugin with it.
self.toggle_view_action = None
示例11: send_args_to_spyder
# 需要导入模块: from spyderlib.config.main import CONF [as 别名]
# 或者: from spyderlib.config.main.CONF import get [as 别名]
def send_args_to_spyder(args):
"""
Simple socket client used to send the args passed to the Spyder
executable to an already running instance.
Args can be Python scripts or files with these extensions: .spydata, .mat,
.npy, or .h5, which can be imported by the Variable Explorer.
"""
port = CONF.get('main', 'open_files_port')
# Wait ~50 secs for the server to be up
# Taken from http://stackoverflow.com/a/4766598/438386
for _x in range(200):
try:
for arg in args:
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM,
socket.IPPROTO_TCP)
client.connect(("127.0.0.1", port))
if is_unicode(arg):
arg = arg.encode('utf-8')
client.send(osp.abspath(arg))
client.close()
except socket.error:
time.sleep(0.25)
continue
break
示例12: test
# 需要导入模块: from spyderlib.config.main import CONF [as 别名]
# 或者: from spyderlib.config.main.CONF import get [as 别名]
def test():
from spyderlib.utils.qthelpers import qapplication
app = qapplication()
from spyderlib.plugins.variableexplorer import VariableExplorer
settings = VariableExplorer.get_settings()
shell = ExternalPythonShell(
pythonexecutable=sys.executable,
interact=True,
stand_alone=settings,
wdir=osp.dirname(__file__),
mpl_backend=0,
light_background=False,
)
from spyderlib.qt.QtGui import QFont
from spyderlib.config.main import CONF
font = QFont(CONF.get("console", "font/family")[0])
font.setPointSize(10)
shell.shell.set_font(font)
shell.shell.toggle_wrap_mode(True)
shell.start_shell(False)
shell.show()
sys.exit(app.exec_())
示例13: set_default_color_scheme
# 需要导入模块: from spyderlib.config.main import CONF [as 别名]
# 或者: from spyderlib.config.main.CONF import get [as 别名]
def set_default_color_scheme(self, name='Spyder'):
"""Set default color scheme (only once)"""
color_scheme_name = self.get_option('color_scheme_name', None)
if color_scheme_name is None:
names = CONF.get("color_schemes", "names")
if name not in names:
name = names[0]
self.set_option('color_scheme_name', name)
示例14: __init__
# 需要导入模块: from spyderlib.config.main import CONF [as 别名]
# 或者: from spyderlib.config.main.CONF import get [as 别名]
def __init__(self, parent, history_filename, profile=False):
"""
parent : specifies the parent widget
"""
ConsoleBaseWidget.__init__(self, parent)
SaveHistoryMixin.__init__(self)
# Prompt position: tuple (line, index)
self.current_prompt_pos = None
self.new_input_line = True
# History
self.histidx = None
self.hist_wholeline = False
assert is_text_string(history_filename)
self.history_filename = history_filename
self.history = self.load_history()
# Session
self.historylog_filename = CONF.get('main', 'historylog_filename',
get_conf_path('history.log'))
# Context menu
self.menu = None
self.setup_context_menu()
# Simple profiling test
self.profile = profile
# Buffer to increase performance of write/flush operations
self.__buffer = []
self.__timestamp = 0.0
self.__flushtimer = QTimer(self)
self.__flushtimer.setSingleShot(True)
self.__flushtimer.timeout.connect(self.flush)
# Give focus to widget
self.setFocus()
# Completion
completion_size = CONF.get('shell_appearance', 'completion/size')
completion_font = get_font('console')
self.completion_widget.setup_appearance(completion_size,
completion_font)
# Cursor width
self.setCursorWidth( CONF.get('shell_appearance', 'cursor/width') )
示例15: shellwidget_config
# 需要导入模块: from spyderlib.config.main import CONF [as 别名]
# 或者: from spyderlib.config.main.CONF import get [as 别名]
def shellwidget_config(self):
"""
Generate a Config instance for shell widgets using our config
system
This lets us create each widget with its own config (as opposed to
IPythonQtConsoleApp, where all widgets have the same config)
"""
# ---- IPython config ----
try:
profile_path = osp.join(get_ipython_dir(), 'profile_default')
full_ip_cfg = load_pyconfig_files(['ipython_qtconsole_config.py'],
profile_path)
# From the full config we only select the IPythonWidget section
# because the others have no effect here.
ip_cfg = Config({'IPythonWidget': full_ip_cfg.IPythonWidget})
except:
ip_cfg = Config()
# ---- Spyder config ----
spy_cfg = Config()
# Make the pager widget a rich one (i.e a QTextEdit)
spy_cfg.IPythonWidget.kind = 'rich'
# Gui completion widget
completion_type_o = CONF.get('ipython_console', 'completion_type')
completions = {0: "droplist", 1: "ncurses", 2: "plain"}
spy_cfg.IPythonWidget.gui_completion = completions[completion_type_o]
# Pager
pager_o = self.get_option('use_pager')
if pager_o:
spy_cfg.IPythonWidget.paging = 'inside'
else:
spy_cfg.IPythonWidget.paging = 'none'
# Calltips
calltips_o = self.get_option('show_calltips')
spy_cfg.IPythonWidget.enable_calltips = calltips_o
# Buffer size
buffer_size_o = self.get_option('buffer_size')
spy_cfg.IPythonWidget.buffer_size = buffer_size_o
# Prompts
in_prompt_o = self.get_option('in_prompt')
out_prompt_o = self.get_option('out_prompt')
if in_prompt_o:
spy_cfg.IPythonWidget.in_prompt = in_prompt_o
if out_prompt_o:
spy_cfg.IPythonWidget.out_prompt = out_prompt_o
# Merge IPython and Spyder configs. Spyder prefs will have prevalence
# over IPython ones
ip_cfg._merge(spy_cfg)
return ip_cfg