本文整理汇总了Python中kivy.config.ConfigParser类的典型用法代码示例。如果您正苦于以下问题:Python ConfigParser类的具体用法?Python ConfigParser怎么用?Python ConfigParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_panel
def update_panel(self):
'''Update the MenuSidebar
'''
self.config_parsers = {}
self.interface.menu.buttons_layout.clear_widgets()
for _file in os.listdir(self.PROFILES_PATH):
_file_path = os.path.join(self.PROFILES_PATH, _file)
config_parser = ConfigParser()
config_parser.read(_file_path)
prof_name = config_parser.getdefault('profile', 'name', 'PROFILE')
if not prof_name.strip():
prof_name = 'PROFILE'
self.config_parsers[
str(prof_name) + '_' + _file_path] = config_parser
for _file in sorted(self.config_parsers):
prof_name = self.config_parsers[_file].getdefault('profile',
'name',
'PROFILE')
if not prof_name.strip():
prof_name = 'PROFILE'
self.add_json_panel(prof_name,
self.config_parsers[_file],
os.path.join(
get_kd_data_dir(),
'settings',
'build_profile.json')
)
# force to show the first profile
first_panel = self.interface.menu.buttons_layout.children[-1].uid
self.interface.content.current_uid = first_panel
示例2: generate_settings
def generate_settings(self):
config = ConfigParser()
if not config.has_section("root"):
self.build_config(config)
settings_panel = Settings() #create instance of Settings
settings_panel.add_json_panel('QFlash Settings', config, 'settings.json')
return settings_panel # show the settings interface
示例3: ProjectSettings
class ProjectSettings(Settings):
'''Subclass of :class:`kivy.uix.settings.Settings` responsible for
showing settings of project.
'''
project = ObjectProperty(None)
'''Reference to :class:`desginer.project_manager.Project`
'''
config_parser = ObjectProperty(None)
'''Config Parser for this class. Instance
of :class:`kivy.config.ConfigParser`
'''
def load_proj_settings(self):
'''This function loads project settings
'''
self.config_parser = ConfigParser()
file_path = os.path.join(self.project.path, PROJ_CONFIG)
if not os.path.exists(file_path):
if not os.path.exists(os.path.dirname(file_path)):
os.makedirs(os.path.dirname(file_path))
CONFIG_TEMPLATE = '''[proj_name]
name = Project
[arguments]
arg =
[env variables]
env =
'''
f = open(file_path, 'w')
f.write(CONFIG_TEMPLATE)
f.close()
self.config_parser.read(file_path)
_dir = os.path.dirname(designer.__file__)
_dir = os.path.split(_dir)[0]
settings_dir = os.path.join(_dir, 'designer', 'settings')
self.add_json_panel('Shell Environment',
self.config_parser,
os.path.join(settings_dir,
'proj_settings_shell_env.json'))
self.add_json_panel('Project Properties',
self.config_parser,
os.path.join(settings_dir,
'proj_settings_proj_prop.json'))
@ignore_proj_watcher
def on_config_change(self, *args):
'''This function is default handler of on_config_change event.
'''
self.config_parser.write()
super(ProjectSettings, self).on_config_change(*args)
示例4: build_my_settings
def build_my_settings(settings, req, result):
for settable in result:
yeah_id = settable[0]
settings_format = settable[1]
my_settings = settable[2]
print yeah_id, settings_format, my_settings
config = ConfigParser()
config.setdefaults(yeah_id, my_settings)
settings.add_json_panel(my_settings['name'], config, data=dumps(settings_format))
示例5: ProjectSettings
class ProjectSettings(Settings):
"""Subclass of :class:`kivy.uix.settings.Settings` responsible for
showing settings of project.
"""
project = ObjectProperty(None)
"""Reference to :class:`desginer.project_manager.Project`
"""
config_parser = ObjectProperty(None)
"""Config Parser for this class. Instance
of :class:`kivy.config.ConfigParser`
"""
def load_proj_settings(self):
"""This function loads project settings
"""
self.config_parser = ConfigParser()
file_path = os.path.join(self.project.path, PROJ_CONFIG)
if not os.path.exists(file_path):
if not os.path.exists(os.path.dirname(file_path)):
os.makedirs(os.path.dirname(file_path))
CONFIG_TEMPLATE = """[proj_name]
name = Project
[arguments]
arg =
[env variables]
env =
"""
f = open(file_path, "w")
f.write(CONFIG_TEMPLATE)
f.close()
self.config_parser.read(file_path)
settings_dir = os.path.join(get_kd_data_dir(), "settings")
self.add_json_panel(
"Shell Environment", self.config_parser, os.path.join(settings_dir, "proj_settings_shell_env.json")
)
self.add_json_panel(
"Project Properties", self.config_parser, os.path.join(settings_dir, "proj_settings_proj_prop.json")
)
@ignore_proj_watcher
def on_config_change(self, *args):
"""This function is default handler of on_config_change event.
"""
self.config_parser.write()
super(ProjectSettings, self).on_config_change(*args)
示例6: build
def build(self):
self.title = core.string_lang_title[:-1] # заголовок окна программы
self.icon = "Data/Images/logo.png" # иконка окна программы
self.use_kivy_settings = False
self.config = ConfigParser()
self.config.read("{}/program.ini".format(core.prog_path))
self.beep = SoundLoader.load("Data/mess_unread.wav")
self.set_variable_from_settings()
# Домашняя страница клиента.
self.start_screen = \
StartScreen(name_buttons_menu=core.name_buttons_menu,
buttons_menu=core.buttons_menu,
buttons_group=core.buttons_group,
previous="Data/Images/logo.png",
title_previous=core.string_lang_title[:-1],
title_image="Data/Images/DV.png",
overflow_image="Data/Images/overflow_image.png",
previous_image="Data/Images/previous_image.png",
events_callback=self.events_program)
self.screen = self.start_screen
Clock.schedule_once(self.read_license, 3)
return self.start_screen
示例7: __init__
def __init__(self):
Screen.__init__(self)
self.name = 'menu'
self.config = ConfigParser()
self.config.add_section("deck")
self.config.add_section("card")
self.config.adddefaultsection("menu")
self.config.set("deck", "start_studying", 1)
self.config.set("deck", "change_deck_mode", "Normal")
self.config.set("deck", "show_list", True)
self.config.set("deck", "undo", True)
self.config.set("deck", "redo", True)
self.config.set("card", "add", "")
self.config.set("card", "edit", True)
self.config.set("card", "remove", True)
self.config.add_callback(self.check_deck_locks, "deck", "redo")
self.config.add_callback(self.check_deck_locks, "deck", "undo")
self.config.add_callback(self.check_card_locks, "card", "edit")
self.config.add_callback(self.check_card_locks, "card", "add")
self.menu = SettingsWithNoMenu()
self.menu.register_type("screen", FlashcardAppManager.SettingNewScreen)
self.menu.register_type("action", FlashcardAppManager.SettingDoAction)
self.menu.add_json_panel("Flashcards", self.config, os.path.join(os.path.dirname(__file__), 'menu.json'))
self.add_widget(self.menu)
示例8: load_proj_settings
def load_proj_settings(self):
'''This function loads project settings
'''
self.config_parser = ConfigParser()
file_path = os.path.join(self.project.path, PROJ_CONFIG)
if not os.path.exists(file_path):
if not os.path.exists(os.path.dirname(file_path)):
os.makedirs(os.path.dirname(file_path))
CONFIG_TEMPLATE = '''[proj_name]
name = Project
[arguments]
arg =
[env variables]
env =
'''
f = open(file_path, 'w')
f.write(CONFIG_TEMPLATE)
f.close()
self.config_parser.read(file_path)
_dir = os.path.dirname(designer.__file__)
_dir = os.path.split(_dir)[0]
settings_dir = os.path.join(_dir, 'designer', 'settings')
self.add_json_panel('Shell Environment',
self.config_parser,
os.path.join(settings_dir,
'proj_settings_shell_env.json'))
self.add_json_panel('Project Properties',
self.config_parser,
os.path.join(settings_dir,
'proj_settings_proj_prop.json'))
示例9: build
def build(self):
self.config = ConfigParser()
self.config.read(join( dirname(__file__),'duplicator.ini') )
print( self.config.get('general','app_background_color') )
#if not self.config.has_section("general"):
# self.config.add_section("general")
self.activeprinter = None
self.printer_pause = 0
self.sm = ScreenManager()
self.sm.add_widget(MenuScreen(name='Menu'))
self.sm.add_widget(PrintScreen(name='Print'))
self.sm.add_widget(ScanScreen(name='Scan'))
self.sm.add_widget(ShareScreen(name='Share'))
self.sm.add_widget(ConfigScreen(name='Config'))
self.sm.add_widget(PlaterScreen(name='Plater'))
self.sm.add_widget(ViewScreen(name='View'))
self.sm.add_widget(FileGcodeLoadScreen(name='FileGcodeLoad'))
self.menu_bar = Factory.MenuBar()
self.sm.get_screen('Menu').ids.window_layout.add_widget(self.menu_bar)
self.menu_bar.ids.short_message.text = 'Duplicator Started\nReady for action.'
self.cam1 = cv2.VideoCapture(0)
return self.sm
示例10: __init__
def __init__(self, **kwargs):
super(NuBippyApp, self).__init__(**kwargs)
self.isPopup = False
self.show_info = False
self.use_kivy_settings = False
# load config file
# we don't display the settings panel, changes can be made manually to the ini file
self.config = ConfigParser()
self.config.read('nubippy.ini')
# Set the language and load the language file
self.language = self.config.get('Language', 'active_language')
try:
self.lang = json.load(open('res/json/languages/' + self.language + '.json', 'r'))
except ValueError as e:
print('')
print('##################################################################')
print('')
print('There was an Error loading the ' + self.language + ' language file.')
print('')
print(str(e))
print('')
print('##################################################################')
raise SystemExit
return
示例11: load_proj_settings
def load_proj_settings(self):
'''This function loads project settings
'''
self.config_parser = ConfigParser()
file_path = os.path.join(self.proj_loader.proj_dir, PROJ_CONFIG)
if not os.path.exists(file_path):
if not os.path.exists(os.path.dirname(file_path)):
os.makedirs(os.path.dirname(file_path))
CONFIG_TEMPLATE = '''[proj_name]
name = Project
[arguments]
arg =
[env variables]
env =
'''
f = open(file_path, 'w')
f.write(CONFIG_TEMPLATE)
f.close()
self.config_parser.read(file_path)
proj_prop_panel = self.create_json_panel('Project Properties', self.config_parser,
'./designer/settings/proj_settings_proj_prop.json')
self.add_widget(proj_prop_panel)
self.add_json_panel('Shell Environment', self.config_parser,
'./designer/settings/proj_settings_shell_env.json')
示例12: load_proj_settings
def load_proj_settings(self):
"""This function loads project settings
"""
self.config_parser = ConfigParser()
file_path = os.path.join(self.project.path, PROJ_CONFIG)
if not os.path.exists(file_path):
if not os.path.exists(os.path.dirname(file_path)):
os.makedirs(os.path.dirname(file_path))
CONFIG_TEMPLATE = """[proj_name]
name = Project
[arguments]
arg =
[env variables]
env =
"""
f = open(file_path, "w")
f.write(CONFIG_TEMPLATE)
f.close()
self.config_parser.read(file_path)
settings_dir = os.path.join(get_kd_data_dir(), "settings")
self.add_json_panel(
"Shell Environment", self.config_parser, os.path.join(settings_dir, "proj_settings_shell_env.json")
)
self.add_json_panel(
"Project Properties", self.config_parser, os.path.join(settings_dir, "proj_settings_proj_prop.json")
)
示例13: do_search
def do_search(self):
def on_success(req, result):
print ('search success.')
for p in result['result']:
p_id = str(p['id'])
if p['code'] is None or p['code'] == '':
subtext = p['name']
else:
subtext = p['code']
image_source = self.get_local_image(p)
btn = Factory.CustomButton(image_source=image_source, id=p_id,
size_hint_y=None, width=300, height=100, subtext=subtext)
btn.bind(on_press=self.do_add_item)
self.products_search_list.append(btn)
self.my_tabbed_panel_wid.grid_layout_search_wid.add_widget(btn)
self.my_tabbed_panel_wid.switch_to(self.my_tabbed_panel_wid.tab_search_wid)
self.my_tabbed_panel_wid.grid_layout_search_wid.height = (len(result['result'])/4+4)*110
self.text_input_wid.text = ''
def on_failure(req, result):
on_error(req, result)
def on_error(req, result):
print ('POSScrean.search().on_error() ')
print ('POSScreen.do_search():')
if len(self.products_search_list) > 0:
for n in self.products_search_list:
self.my_tabbed_panel_wid.grid_layout_search_wid.remove_widget(n)
self.products_search_list = []
config = ConfigParser.get_configparser(name='app')
producturl = config.get('serverconnection', 'server.url') + "pos/product/" + self.text_input_wid.text
UrlRequest(producturl, on_success=on_success, on_failure=on_failure, on_error=on_error)
示例14: load_settings
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()
示例15: load_settings
def load_settings(self):
'''This function loads project settings
'''
self.config_parser = ConfigParser(name='DesignerSettings')
DESIGNER_CONFIG = os.path.join(get_config_dir(),
constants.DESIGNER_CONFIG_FILE_NAME)
DEFAULT_CONFIG = os.path.join(get_kd_dir(),
constants.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(get_kd_data_dir(),
'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(get_kd_data_dir(), 'settings',
'buildozer_settings.json'))
self.add_json_panel('Hanga', self.config_parser,
os.path.join(get_kd_data_dir(), 'settings',
'hanga_settings.json'))
self.add_json_panel('Keyboard Shortcuts', self.config_parser,
os.path.join(get_kd_data_dir(), 'settings',
'shortcuts.json'))