本文整理汇总了Python中spyderlib.config.main.CONF类的典型用法代码示例。如果您正苦于以下问题:Python CONF类的具体用法?Python CONF怎么用?Python CONF使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CONF类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: long_banner
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
开发者ID:MarvinLiu0810,项目名称:spyder,代码行数:25,代码来源:ipython.py
示例2: set_option
def set_option(self, option, value):
"""
Set a plugin option in configuration file
Use a SIGNAL to call it, e.g.:
plugin.sig_option_changed.emit('show_all', checked)
"""
CONF.set(self.CONF_SECTION, str(option), value)
开发者ID:DLlearn,项目名称:spyder,代码行数:7,代码来源:__init__.py
示例3: get_font
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
开发者ID:erpangwang01,项目名称:spyder,代码行数:25,代码来源:gui.py
示例4: update_margins
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)
开发者ID:DLlearn,项目名称:spyder,代码行数:9,代码来源:__init__.py
示例5: _get_run_configurations
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 []
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:9,代码来源:runconfig.py
示例6: __init__
def __init__(self, parent=None):
QDialog.__init__(self, parent)
self.main = parent
# Widgets
self.pages_widget = QStackedWidget()
self.contents_widget = QListWidget()
self.button_reset = QPushButton(_('Reset to defaults'))
bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Apply |
QDialogButtonBox.Cancel)
self.apply_btn = bbox.button(QDialogButtonBox.Apply)
# Widgets setup
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
self.setWindowTitle(_('Preferences'))
self.setWindowIcon(ima.icon('configure'))
self.contents_widget.setMovement(QListView.Static)
self.contents_widget.setSpacing(1)
self.contents_widget.setCurrentRow(0)
# Layout
hsplitter = QSplitter()
hsplitter.addWidget(self.contents_widget)
hsplitter.addWidget(self.pages_widget)
btnlayout = QHBoxLayout()
btnlayout.addWidget(self.button_reset)
btnlayout.addStretch(1)
btnlayout.addWidget(bbox)
vlayout = QVBoxLayout()
vlayout.addWidget(hsplitter)
vlayout.addLayout(btnlayout)
self.setLayout(vlayout)
# Signals and slots
self.button_reset.clicked.connect(self.main.reset_spyder)
self.pages_widget.currentChanged.connect(self.current_page_changed)
self.contents_widget.currentRowChanged.connect(
self.pages_widget.setCurrentIndex)
bbox.accepted.connect(self.accept)
bbox.rejected.connect(self.reject)
bbox.clicked.connect(self.button_clicked)
# Ensures that the config is present on spyder first run
CONF.set('main', 'interface_language', load_lang_conf())
开发者ID:gyenney,项目名称:Tools,代码行数:53,代码来源:configdialog.py
示例7: external_editor
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)
开发者ID:dimikara,项目名称:spyder,代码行数:12,代码来源:internalshell.py
示例8: external_editor
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)
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:13,代码来源:internalshell.py
示例9: set_font
def set_font(font, section='main', option='font'):
"""Set font"""
CONF.set(section, option+'/family', to_text_string(font.family()))
CONF.set(section, option+'/size', float(font.pointSize()))
CONF.set(section, option+'/italic', int(font.italic()))
CONF.set(section, option+'/bold', int(font.bold()))
FONT_CACHE[(section, option)] = font
开发者ID:erpangwang01,项目名称:spyder,代码行数:7,代码来源:gui.py
示例10: test
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_())
开发者ID:MarvinLiu0810,项目名称:spyder,代码行数:29,代码来源:pythonshell.py
示例11: send_args_to_spyder
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
开发者ID:MarvinLiu0810,项目名称:spyder,代码行数:26,代码来源:start_app.py
示例12: __init__
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
开发者ID:DLlearn,项目名称:spyder,代码行数:26,代码来源:__init__.py
示例13: __init__
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
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:16,代码来源:runconfig.py
示例14: setup_page
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)
开发者ID:gyenney,项目名称:Tools,代码行数:35,代码来源:history.py
示例15: __init__
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') )
开发者ID:gyenney,项目名称:Tools,代码行数:46,代码来源:shell.py
示例16: set_default_color_scheme
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)
开发者ID:erpangwang01,项目名称:spyder,代码行数:8,代码来源:__init__.py
示例17: shellwidget_config
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
开发者ID:MarvinLiu0810,项目名称:spyder,代码行数:58,代码来源:ipython.py
示例18: set_font
def set_font(font, section, option=None):
"""Set font"""
if option is None:
option = 'font'
else:
option += '/font'
CONF.set(section, option+'/family', to_text_string(font.family()))
CONF.set(section, option+'/size', float(font.pointSize()))
CONF.set(section, option+'/italic', int(font.italic()))
CONF.set(section, option+'/bold', int(font.bold()))
FONT_CACHE[(section, option)] = font
开发者ID:AungWinnHtut,项目名称:spyder,代码行数:11,代码来源:gui.py
示例19: _banner_default
def _banner_default(self):
"""
Reimplement banner creation to let the user decide if he wants a
banner or not
"""
banner_o = CONF.get('ipython_console', 'show_banner', True)
if banner_o:
return self.long_banner()
else:
return self.short_banner()
开发者ID:MarvinLiu0810,项目名称:spyder,代码行数:10,代码来源:ipython.py
示例20: get_settings
def get_settings():
"""
Return Variable Explorer settings dictionary
(i.e. namespace browser settings according to Spyder's configuration file)
"""
settings = {}
# CONF.load_from_ini() # necessary only when called from another process
for name in REMOTE_SETTINGS:
settings[name] = CONF.get(VariableExplorer.CONF_SECTION, name)
return settings
开发者ID:AminJamalzadeh,项目名称:spyder,代码行数:10,代码来源:variableexplorer.py
注:本文中的spyderlib.config.main.CONF类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论