add example application with ConfigParserProperty

This commit is contained in:
Gabriel Pettier 2017-11-27 20:45:13 +01:00
parent 0456eff89b
commit 67f7deef07
1 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,43 @@
from kivy.app import App
from kivy.lang import Builder
from kivy.properties import ConfigParserProperty
KV = '''
FloatLayout:
BoxLayout:
size_hint: .5, .5
pos_hint: {'center': (.5, .5)}
orientation: 'vertical'
TextInput:
text: app.text
on_text: app.text = self.text
Slider:
min: 0
max: 100
value: app.number
on_value: app.number = self.value
'''
class ConfigApp(App):
number = ConfigParserProperty(0, 'general', 'number', 'app', val_type=float)
text = ConfigParserProperty('', 'general', 'text', 'app', val_type=str)
def build_config(self, config):
config.setdefaults(
'general',
{
'number': 0,
'text': 'test'
}
)
def build(self):
return Builder.load_string(KV)
if __name__ == '__main__':
ConfigApp().run()