It is often mentioned on the net, but since there is little information in books etc., it is a memo.
Kivy has a settings screen by default. You can open it by pressing F1 while the Kivy application is running.
This allows you to change Kivy settings so you can use it for simple debugging. This settings screen is customizable and you can create settings for your application.
First, prepare the setting file.
myconf.ini
[section1]
key1 = value1
key2 = 40
Next, prepare JSON to add a panel for setting.
settings_custom.json
[
{
"type": "title",
"title": "Windows"
},
{
"type": "options",
"title": "Test",
"desc": "test settings",
"section": "section1",
"key": "key1",
"options": ["value1", "value2", "value3"]
},
{
"type": "numeric",
"title": "Test",
"desc": "test settings2",
"section": "section1",
"key": "key2"
}
]
Finally, you can write as follows.
main.py
# -*- coding: utf-8 -*-
import kivy
kivy.require('1.9.0')
#For setting
from kivy.config import ConfigParser
from kivy.uix.button import Button
from kivy.app import App
class sampleApp(App):
def build_config(self, config):
#Use a file for settings(myconf.ini)
config.read('myconf.ini')
def build_settings(self, settings):
#Added a panel for settings(settings_custom.json')
settings.add_json_panel('Setting Panel', self.config, filename='settings_custom.json')
def build(self):
return Button(text='hello world')
if __name__ == '__main__':
sampleApp().run()
When I run the application and press F1
The custom settings screen is displayed.
that's all. It was an explanation of the setting screen. Please feel free to let me know if you have any questions such as "I'm wrong".
As usual, I would appreciate your favor in the Kivy study session. http://pyky.connpass.com/