本文整理汇总了Python中kivy.config.ConfigParser.adddefaultsection方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigParser.adddefaultsection方法的具体用法?Python ConfigParser.adddefaultsection怎么用?Python ConfigParser.adddefaultsection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.config.ConfigParser
的用法示例。
在下文中一共展示了ConfigParser.adddefaultsection方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_config
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import adddefaultsection [as 别名]
def get_config():
config = ConfigParser()
config.read('config.ini')
config.adddefaultsection('game')
config.setdefault('game', 'outside_coordinates', True)
config.setdefault('game', 'show_pieces', True)
config.setdefault('game', 'square_coordinates', False)
return config
示例2: NewGame
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import adddefaultsection [as 别名]
class NewGame(AnchorLayout):
app = ObjectProperty(None)
config = ObjectProperty(None)
settings = ObjectProperty(None)
def __init__(self, **kwargs):
super(NewGame, self).__init__(**kwargs)
self.config = ConfigParser()
self.config.read(tttraders_user_conf('tttraders.ini'))
self.settings.register_type("int", TTSettingInt)
for tab in TradersGame.ConfigTabs:
lst = TradersGame.Config[tab]
for c in lst:
if c.get("key", None):
self.config.adddefaultsection(c['section'])
self.config.setdefault(c['section'], c['key'], c.get("default", None))
self.settings.add_json_panel(tab, self.config, data=json.dumps(lst))
示例3: MenuScreen
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import adddefaultsection [as 别名]
class MenuScreen(Screen):
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)
def check_deck_locks(self, section, key, value):
print(self.config.get(section, key))
def check_card_locks(self, section, key, value):
print()
示例4: ConfigParser
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import adddefaultsection [as 别名]
from kivy.factory import Factory
from kivy.app import App
from kivy.properties import StringProperty
from kivy.lang import Builder
import csv
import os
import json
app = App.get_running_app()
from kivy.config import ConfigParser
config = ConfigParser()
config.read('myconfig.ini')
config.adddefaultsection('pycon2018')
config.setdefault('pycon2018', 'register_data_dir', 'data')
class ScreenRegister(Factory.Screen):
_data = {}
'''Holds the data in :attr:`data_file_dir` was processed or not.
:attr:`_data` is a :type:`String`, defaults to False.
'''
data_file_dir = StringProperty(config.get(
'pycon2018', 'register_data_dir'))
'''This is the data dir where the registeration data is stored.
All csv files should be present in this folder.
示例5: UserPrefs
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import adddefaultsection [as 别名]
#.........这里部分代码省略.........
def get_last_selected_track_id(self):
return self.get_pref('track_detection', 'last_selected_track_id')
def get_last_selected_track_timestamp(self):
return self.get_pref_int('track_detection', 'last_selected_track_timestamp')
def get_user_cancelled_location(self):
return self.get_pref('track_detection', 'user_cancelled_location')
def set_last_selected_track(self, track_id, timestamp, user_cancelled_location='0,0'):
self.set_pref('track_detection', 'last_selected_track_id', track_id)
self.set_pref('track_detection', 'last_selected_track_timestamp', timestamp)
self.set_pref('track_detection', 'user_cancelled_location', user_cancelled_location)
self.save()
@property
def datastore_location(self):
return os.path.join(self.data_dir, 'datastore.sq3')
def save(self, *largs):
'''
Saves the current configuration
'''
Logger.info('UserPrefs: Saving preferences')
with open(self.prefs_file, 'w+') as prefs_file:
data = self.to_json()
prefs_file.write(data)
def set_config_defaults(self):
'''
Set defaults for preferences
'''
# Base system preferences
self.config.adddefaultsection('help')
self.config.adddefaultsection('preferences')
self.config.setdefault('preferences', 'distance_units', 'miles')
self.config.setdefault('preferences', 'temperature_units', 'Fahrenheit')
self.config.setdefault('preferences', 'show_laptimes', 1)
self.config.setdefault('preferences', 'startup_screen', 'Home Page')
default_user_files_dir = self.user_files_dir
self.config.setdefault('preferences', 'config_file_dir', default_user_files_dir)
self.config.setdefault('preferences', 'export_file_dir', default_user_files_dir)
self.config.setdefault('preferences', 'firmware_dir', default_user_files_dir)
self.config.setdefault('preferences', 'import_datalog_dir', default_user_files_dir)
self.config.setdefault('preferences', 'send_telemetry', '0')
self.config.setdefault('preferences', 'record_session', '1')
self.config.setdefault('preferences', 'global_help', True)
# Connection type for mobile
if is_mobile_platform():
if is_android():
self.config.setdefault('preferences', 'conn_type', 'Bluetooth')
elif is_ios():
self.config.setdefault('preferences', 'conn_type', 'WiFi')
else:
self.config.setdefault('preferences', 'conn_type', 'Serial')
# Dashboard preferences
self.config.adddefaultsection('dashboard_preferences')
self.config.setdefault('dashboard_preferences', 'last_dash_screen', '5x_gauge_view')
self.config.setdefault('dashboard_preferences', 'pitstoptimer_enabled', 1)
self.config.setdefault('dashboard_preferences', 'pitstoptimer_trigger_speed', 5)
self.config.setdefault('dashboard_preferences', 'pitstoptimer_alert_speed', 25)
self.config.setdefault('dashboard_preferences', 'pitstoptimer_exit_speed', 55)
# Track detection pref