from kivy.factory import Factory from kivy.uix.button import Button Factory.register('MyCustomButton', cls=Button) # Use the custom button in kvlang: MyCustomButton: text: "Click me"
from kivy.factory import Factory from kivy.uix.label import Label class MyLabel(Label): pass Factory.register('MyLabel', cls=MyLabel) # Use the custom label in kvlangIn both examples, `Factory.register` is used to register the custom widget class with a name so that it can be used in the kvlang. The first argument of `Factory.register` is the name of the custom widget, and the second argument is the class to be instantiated. `kivy.factory.Factory` is a part of the Kivy package library.: MyLabel: text: "Hello world"