diff --git a/examples/application/app_with_config.py b/examples/application/app_with_config.py new file mode 100644 index 000000000..d77b6b628 --- /dev/null +++ b/examples/application/app_with_config.py @@ -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()