Version

Quick search

Table Of Contents

Parser utilities

Helper functions used for CSS parsing.

kivy.parser.parse_bool(text)[source]

Parse a string to a boolean, ignoring case. “true”/”1” is True, “false”/”0” is False. Anything else throws an exception.

kivy.parser.parse_color(text)[source]

Parse a string to a kivy color. Supported formats:

  • rgb(r, g, b)

  • rgba(r, g, b, a)

  • rgb

  • rgba

  • rrggbb

  • rrggbbaa

For hexadecimal values, you case also use:

  • #rgb

  • #rgba

  • #rrggbb

  • #rrggbbaa

kivy.parser.parse_filename(filename)[source]

Parse a filename and search for it using resource_find(). If found, the resource path is returned, otherwise return the unmodified filename (as specified by the caller).

kivy.parser.parse_float

alias of float

kivy.parser.parse_float4(text)[source]

Parse a string to a list of exactly 4 floats.

>>> parse_float4('54 87. 35 0')
54, 87., 35, 0
kivy.parser.parse_int

alias of int

kivy.parser.parse_int2(text)[source]

Parse a string to a list of exactly 2 integers.

>>> print(parse_int2("12 54"))
12, 54
kivy.parser.parse_string(text)[source]

Parse a string to a string (removing single and double quotes).