You can download this code by clicking the button below.
This code is now available for download.
This function creates a custom button that can dynamically bind its text to a string property.
Technology Stack : Kivy, Button, StringProperty
Code Type : Kivy UI component
Code Difficulty : Intermediate
def random_button_text(label, text):
from kivy.uix.button import Button
from kivy.properties import StringProperty
class RandomButton(Button):
text = StringProperty()
def __init__(self, **kwargs):
super(RandomButton, self).__init__(**kwargs)
self.text = text
self.bind(text=label)
return RandomButton()