Configuration object¶
Config object is an instance of a modified Python ConfigParser. See ConfigParser documentation for more information.
Usage of Config object¶
Read a configuration token from a particular section:
>>> from kivy.config import Config
>>> Config.getint('kivy', 'show_fps')
0
Change the configuration and save it:
>>> Config.set('kivy', 'retain_time', 50)
>>> Config.write()
Available configuration tokens¶
kivy: |
|
---|---|
postproc: |
|
graphics: |
|
input: | Input section is particular. You can create new input device with this syntax: # example of input provider instance
yourid = providerid,parameters
# example for tuio provider
default = tuio,127.0.0.1:3333
mytable = tuio,192.168.0.1:3334
See also Check all the providers in kivy.input.providers for the syntax to use inside the configuration file. |
widgets: |
|
modules: | You can activate modules with this syntax: modulename =
Anything after the = will be passed to the module as arguments. Check the specific module’s documentation for a list of accepted arguments. |
Changed in version 1.2.0: resizable has been added to graphics section
Changed in version 1.1.0: tuio is not listening by default anymore. windows icons are not copied to user directory anymore. You can still set a new window icon by using window_icon config setting.
Changed in version 1.0.8: scroll_timeout, scroll_distance and scroll_friction have been added. list_friction, list_trigger_distance and list_friction_bound have been removed. keyboard_type and keyboard_layout have been removed from widget. keyboard_mode and keyboard_layout have been added to kivy section.
- kivy.config.Config = None¶
Kivy configuration object
- class kivy.config.ConfigParser¶
Bases: ConfigParser.ConfigParser
Enhanced ConfigParser class, that supports addition of default sections and default values.
New in version 1.0.7.
- add_callback(callback, section=None, key=None)¶
Add a callback to be called when a specific section/key changed. If you don’t specify a section or a key, it will call the callback for all section/keys.
Callbacks will receive 3 arguments: the section, key and value.
New in version 1.4.1.
- adddefaultsection(section)¶
Add a section if the section is missing.
- getdefault(section, option, defaultvalue)¶
Get an option. If not found, it will return the default value
- read(filename)¶
Read only one filename. In contrast to the original ConfigParser of Python, this one is able to read only one file at a time. The latest read file will be used for the write() method.
- set(section, option, value)¶
Functions similarly to PythonConfigParser’s set method, except that the value is implicitly converted to a string.
- setdefault(section, option, value)¶
Set the default value of a particular option
- setdefaults(section, keyvalues)¶
Set a lot of keys/values in one section at the same time