Applying utils
There are some methods in Kivy that cannot be arranged in any other class. They are miscellaneous and could be helpful in some contexts. In this recipe, we will see how to use them.
How to do it…
In the spirit to show all the methods available, let's work directly in Python. To do the package tour, follow these steps:
Import the
kivy
package.from kivy.utils import *
Find the intersection between two lists.
intersection(('a',1,2), (1,2))
Find the difference between two lists.
difference(('a',1,2), (1,2))
Convert a tuple in a string.
strtotuple("1,2")
Transform a hex string color to a Kivy color.
get_color_from_hex('#000000')
Transform a Kivy color to a hex value.
get_hex_from_color((0, 1, 0))
Get a random color.
get_random_color(alpha='random')
Evaluate if a color is transparent.
is_color_transparent((0,0,0,0))
Limit the value between a minimum value and maximum value.
boundary(a,1,2)
Interpolate between two values.
interpolate(10, 50, step=10)
Mark a function as deprecated.
...