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:

  1. Import the kivy package.
    from kivy.utils import *
    
  2. Find the intersection between two lists.
    intersection(('a',1,2), (1,2))
    
  3. Find the difference between two lists.
    difference(('a',1,2), (1,2))
    
  4. Convert a tuple in a string.
    strtotuple("1,2")
    
  5. Transform a hex string color to a Kivy color.
    get_color_from_hex('#000000')
    
  6. Transform a Kivy color to a hex value.
    get_hex_from_color((0, 1, 0))
    
  7. Get a random color.
    get_random_color(alpha='random') ...

Get Kivy Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.