def create_app_settings(self, config, settings):
app_list = get_plugins_list()
for app in app_list:
APP_NAME = app
APP_DIR = app_list[app][0]
setting_path = os.path.join(APP_DIR, "settings.json")
if os.path.exists(setting_path):
with open(setting_path, "r") as settings_json:
raw_data = settings_json.read()
# Regulate the config into the format that kivy can accept
tmp = eval(raw_data)
result = "["
default_val = {}
for index in range(len(tmp)):
if tmp[index]['type'] == 'title':
result = result + '{"type": "title","title": ""},'
elif tmp[index]['type'] == 'options':
default_val[tmp[index]['key']
] = tmp[index]['default']
result = result + '{"type": "' + tmp[index]['type'] \
+ '","title":"' + tmp[index]['title'] \
+ '","desc":"' + tmp[index]['desc'] \
+ '","section":"' + APP_NAME \
+ '","key":"' + tmp[index]['key'] \
+ '","options":' + json.dumps(tmp[index]['options']) \
+ '},'
else:
default_val[tmp[index]['key']
] = tmp[index]['default']
result = result + '{"type": "' + tmp[index]['type'] \
+ '","title":"' + tmp[index]['title'] \
+ '","desc":"' + tmp[index]['desc'] \
+ '","section":"' + APP_NAME \
+ '","key":"' + tmp[index]['key'] \
+ '"},'
result = result[0:-1] + "]"
# Update the default value and setting menu
settings.add_json_panel(APP_NAME, config, data=result)
评论列表
文章目录