本文整理汇总了Python中kivy.config.ConfigParser.upgrade方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigParser.upgrade方法的具体用法?Python ConfigParser.upgrade怎么用?Python ConfigParser.upgrade使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.config.ConfigParser
的用法示例。
在下文中一共展示了ConfigParser.upgrade方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DesignerSettings
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import upgrade [as 别名]
class DesignerSettings(Settings):
'''Subclass of :class:`kivy.uix.settings.Settings` responsible for
showing settings of Kivy Designer.
'''
config_parser = ObjectProperty(None)
'''Config Parser for this class. Instance
of :class:`kivy.config.ConfigParser`
'''
def load_settings(self):
'''This function loads project settings
'''
self.config_parser = ConfigParser()
DESIGNER_CONFIG = os.path.join(get_kivy_designer_dir(),
DESIGNER_CONFIG_FILE_NAME)
_dir = os.path.dirname(designer.__file__)
_dir = os.path.split(_dir)[0]
DEFAULT_CONFIG = os.path.join(_dir, DESIGNER_CONFIG_FILE_NAME)
if not os.path.exists(DESIGNER_CONFIG):
shutil.copyfile(DEFAULT_CONFIG,
DESIGNER_CONFIG)
self.config_parser.read(DESIGNER_CONFIG)
self.config_parser.upgrade(DEFAULT_CONFIG)
self.add_json_panel('Kivy Designer Settings', self.config_parser,
os.path.join(_dir, 'designer',
'settings', 'designer_settings.json'))
path = self.config_parser.getdefault(
'global', 'python_shell_path', '')
if path == "":
self.config_parser.set('global', 'python_shell_path',
sys.executable)
self.config_parser.write()
def on_config_change(self, *args):
'''This function is default handler of on_config_change event.
'''
self.config_parser.write()
super(DesignerSettings, self).on_config_change(*args)
示例2: DesignerSettings
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import upgrade [as 别名]
class DesignerSettings(Settings):
'''Subclass of :class:`kivy.uix.settings.Settings` responsible for
showing settings of Kivy Designer.
'''
config_parser = ObjectProperty(None)
'''Config Parser for this class. Instance
of :class:`kivy.config.ConfigParser`
'''
def __init__(self, **kwargs):
super(DesignerSettings, self).__init__(*kwargs)
self.register_type('list', SettingList)
self.register_type('shortcut', SettingShortcut)
def load_settings(self):
'''This function loads project settings
'''
self.config_parser = ConfigParser(name='DesignerSettings')
DESIGNER_CONFIG = os.path.join(get_config_dir(),
DESIGNER_CONFIG_FILE_NAME)
_dir = os.path.dirname(designer.__file__)
_dir = os.path.split(_dir)[0]
DEFAULT_CONFIG = os.path.join(_dir, DESIGNER_CONFIG_FILE_NAME)
if not os.path.exists(DESIGNER_CONFIG):
shutil.copyfile(DEFAULT_CONFIG,
DESIGNER_CONFIG)
self.config_parser.read(DESIGNER_CONFIG)
self.config_parser.upgrade(DEFAULT_CONFIG)
# creates a panel before insert it to update code input theme list
panel = self.create_json_panel('Kivy Designer Settings',
self.config_parser,
os.path.join(_dir, 'designer',
'settings', 'designer_settings.json'))
uid = panel.uid
if self.interface is not None:
self.interface.add_panel(panel, 'Kivy Designer Settings', uid)
# loads available themes
for child in panel.children:
if child.id == 'code_input_theme_options':
child.items = styles.get_all_styles()
# tries to find python and buildozer path if it's not defined
path = self.config_parser.getdefault(
'global', 'python_shell_path', '')
if path.strip() == '':
self.config_parser.set('global', 'python_shell_path',
sys.executable)
self.config_parser.write()
buildozer_path = self.config_parser.getdefault('buildozer',
'buildozer_path', '')
if buildozer_path.strip() == '':
buildozer_path = find_executable('buildozer')
if buildozer_path:
self.config_parser.set('buildozer',
'buildozer_path',
buildozer_path)
self.config_parser.write()
self.add_json_panel('Buildozer', self.config_parser,
os.path.join(_dir, 'designer', 'settings',
'buildozer_settings.json'))
self.add_json_panel('Hanga', self.config_parser,
os.path.join(_dir, 'designer', 'settings',
'hanga_settings.json'))
self.add_json_panel('Keyboard Shortcuts', self.config_parser,
os.path.join(_dir, 'designer', 'settings',
'shortcuts.json'))
def on_config_change(self, *args):
'''This function is default handler of on_config_change event.
'''
self.config_parser.write()
super(DesignerSettings, self).on_config_change(*args)
示例3: DesignerSettings
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import upgrade [as 别名]
class DesignerSettings(Settings):
"""Subclass of :class:`kivy.uix.settings.Settings` responsible for
showing settings of Kivy Designer.
"""
config_parser = ObjectProperty(None)
"""Config Parser for this class. Instance
of :class:`kivy.config.ConfigParser`
"""
def __init__(self, **kwargs):
super(DesignerSettings, self).__init__(*kwargs)
self.register_type("list", SettingList)
self.register_type("shortcut", SettingShortcut)
def load_settings(self):
"""This function loads project settings
"""
self.config_parser = ConfigParser(name="DesignerSettings")
DESIGNER_CONFIG = os.path.join(get_kivy_designer_dir(), DESIGNER_CONFIG_FILE_NAME)
_dir = os.path.dirname(designer.__file__)
_dir = os.path.split(_dir)[0]
DEFAULT_CONFIG = os.path.join(_dir, DESIGNER_CONFIG_FILE_NAME)
if not os.path.exists(DESIGNER_CONFIG):
shutil.copyfile(DEFAULT_CONFIG, DESIGNER_CONFIG)
self.config_parser.read(DESIGNER_CONFIG)
self.config_parser.upgrade(DEFAULT_CONFIG)
# creates a panel before insert it to update code input theme list
panel = self.create_json_panel(
"Kivy Designer Settings",
self.config_parser,
os.path.join(_dir, "designer", "settings", "designer_settings.json"),
)
uid = panel.uid
if self.interface is not None:
self.interface.add_panel(panel, "Kivy Designer Settings", uid)
# loads available themes
for child in panel.children:
if child.id == "code_input_theme_options":
child.items = styles.get_all_styles()
# tries to find python and buildozer path if it's not defined
path = self.config_parser.getdefault("global", "python_shell_path", "")
if path.strip() == "":
self.config_parser.set("global", "python_shell_path", sys.executable)
self.config_parser.write()
buildozer_path = self.config_parser.getdefault("buildozer", "buildozer_path", "")
if buildozer_path.strip() == "":
buildozer_path = find_executable("buildozer")
if buildozer_path:
self.config_parser.set("buildozer", "buildozer_path", buildozer_path)
self.config_parser.write()
self.add_json_panel(
"Buildozer", self.config_parser, os.path.join(_dir, "designer", "settings", "buildozer_settings.json")
)
self.add_json_panel(
"Hanga", self.config_parser, os.path.join(_dir, "designer", "settings", "hanga_settings.json")
)
self.add_json_panel(
"Keyboard Shortcuts", self.config_parser, os.path.join(_dir, "designer", "settings", "shortcuts.json")
)
def on_config_change(self, *args):
"""This function is default handler of on_config_change event.
"""
self.config_parser.write()
super(DesignerSettings, self).on_config_change(*args)