Random Text and Color Label Generator

  • Share this:

Code introduction


This function generates a layout containing a Kivy label with random text and color.


Technology Stack : Kivy

Code Type : Kivy App

Code Difficulty : Intermediate


                
                    
from random import randint
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label

def generate_random_label(text="Random Text", color=(1, 0, 0)):
    def build():
        layout = BoxLayout(orientation='vertical', size_hint=(1, 1))
        label = Label(text=text, color=color)
        layout.add_widget(label)
        return layout
    
    return build                
              
Tags: