Quick search

Configuration object

The Config object is an instance of a modified Python ConfigParser. See the ConfigParser documentation for more information.

Kivy has a configuration file which determines the default settings. In order to change these settings, you can alter this file manually or use the Config object. Please see the Configure Kivy section for more information.

Usage of the Config object

To 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()

Changed in version 1.7.1: The ConfigParser should work correctly with utf-8 now. The values are converted from ascii to unicode only when needed. The method get() returns utf-8 strings.

Available configuration tokens

kivy:
desktop: int, 0 or 1

This option controls desktop OS specific features, such as enabling drag-able scroll-bar in scroll views, disabling of bubbles in TextInput etc. 0 is disabled, 1 is enabled.

exit_on_escape: int, 0 or 1

Enables exiting kivy when escape is pressed. 0 is disabled, 1 is enabled.

log_level: string, one of ‘debug’, ‘info’, ‘warning’, ‘error’ or ‘critical’

Set the minimum log level to use.

log_dir: string

Path of log directory.

log_name: string

Format string to use for the filename of log file.

log_enable: int, 0 or 1

Activate file logging. 0 is disabled, 1 is enabled.

keyboard_mode: string

Specifies the keyboard mode to use. If can be one of the following:

  • ‘’ - Let Kivy choose the best option for your current platform.
  • ‘system’ - real keyboard.
  • ‘dock’ - one virtual keyboard docked to a screen side.
  • ‘multi’ - one virtual keyboard for every widget request.
  • ‘systemanddock’ - virtual docked keyboard plus input from real keyboard.
  • ‘systemandmulti’ - analogous.
keyboard_layout: string

Identifier of the layout to use.

window_icon: string

Path of the window icon. Use this if you want to replace the default pygame icon.

postproc:
double_tap_time: int

Time allowed for the detection of double tap, in milliseconds.

double_tap_distance: float

Maximum distance allowed for a double tap, normalized inside the range 0 - 1000.

triple_tap_time: int

Time allowed for the detection of triple tap, in milliseconds.

triple_tap_distance: float

Maximum distance allowed for a triple tap, normalized inside the range 0 - 1000.

retain_time: int

Time allowed for a retain touch, in milliseconds.

retain_distance: int

If the touch moves more than is indicated by retain_distance, it will not be retained. Argument should be an int between 0 and 1000.

jitter_distance: int

Maximum distance for jitter detection, normalized inside the range 0 - 1000.

jitter_ignore_devices: string, separated with commas

List of devices to ignore from jitter detection.

ignore: list of tuples

List of regions where new touches are ignored. This configuration token can be used to resolve hotspot problems with DIY hardware. The format of the list must be:

ignore = [(xmin, ymin, xmax, ymax), ...]

All the values must be inside the range 0 - 1.

graphics:
maxfps: int, defaults to 60

Maximum FPS allowed.

fullscreen: int or string, one of 0, 1, ‘fake’ or ‘auto’

Activate fullscreen. If set to 1, a resolution of width times height pixels will be used. If set to auto, your current display’s resolution will be used instead. This is most likely what you want. If you want to place the window in another display, use fake and adjust width, height, top and left.

width: int

Width of the Window, not used if fullscreen is set to auto.

height: int

Height of the Window, not used if fullscreen is set to auto.

fbo: string, one of ‘hardware’, ‘software’ or ‘force-hardware’

Selects the FBO backend to use.

show_cursor: int, one of 0 or 1

Show the cursor on the screen.

position: string, one of ‘auto’ or ‘custom’

Position of the window on your display. If auto is used, you have no control of the initial position: top and left are ignored.

top: int

Top position of the Window.

left: int

Left position of the Window.

rotation: int, one of 0, 90, 180 or 270

Rotation of the Window.

resizable: int, one of 0 or 1

If 0, the window will have a fixed size. If 1, the window will be resizable.

input:

You can create new input devices using 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 the providers in kivy.input.providers for the syntax to use inside the configuration file.

widgets:
scroll_distance: int

Default value of the scroll_distance property used by the ScrollView widget. Check the widget documentation for more information.

scroll_friction: float

Default value of the scroll_friction property used by the ScrollView widget. Check the widget documentation for more information.

scroll_timeout: int

Default value of the scroll_timeout property used by the ScrollView widget. Check the widget documentation for more information.

scroll_stoptime: int

Default value of the scroll_stoptime property used by the ScrollView widget. Check the widget documentation for more information.

Deprecated since version 1.7.0: Please use effect_cls instead.

scroll_moves: int

Default value of the scroll_moves property used by the ScrollView widget. Check the widget documentation for more information.

Deprecated since version 1.7.0: Please use effect_cls instead.

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.8.0: systemanddock and systemandmulti has been added as possible values for keyboard_mode in the kivy section. exit_on_escape has been added to the kivy section.

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. Window icons are not copied to user directory anymore. You can still set a new window icon by using the 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 the widget. keyboard_mode and keyboard_layout have been added to the kivy section.

kivy.config.Config = None

Kivy configuration object

class kivy.config.ConfigParser[source]

Bases: ConfigParser.ConfigParser

Enhanced ConfigParser class that supports the addition of default sections and default values.

New in version 1.0.7.

add_callback(callback, section=None, key=None)[source]

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 changes.

Callbacks will receive 3 arguments: the section, key and value.

New in version 1.4.1.

adddefaultsection(section)[source]

Add a section if the section is missing.

getdefault(section, option, defaultvalue)[source]

Get an option. If not found, it will return the default value.

getdefaultint(section, option, defaultvalue)[source]

Get an option. If not found, it will return the default value. The return value will be always converted as an integer.

New in version 1.6.0.

read(filename)[source]

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 last read file will be used for the write() method.

set(section, option, value)[source]

Functions similarly to PythonConfigParser’s set method, except that the value is implicitly converted to a string.

setdefault(section, option, value)[source]

Set the default value of a particular option.

setdefaults(section, keyvalues)[source]

Set a lot of keys/values in one section at the same time.

write()[source]
Write the configuration to the last file opened using the
read() method.

Return True if the write finished successfully.