Factory object¶
The factory can be used to automatically import any class from a module, by specifying the module to import instead of the class instance.
The class list and available modules are automatically generated by setup.py.
Example for registering a class/module:
>>> from kivy.factory import Factory
>>> Factory.register('Widget', module='kivy.uix.widget')
>>> Factory.register('Vector', module='kivy.vector')
Example of using the Factory:
>>> from kivy.factory import Factory
>>> widget = Factory.Widget(pos=(456,456))
>>> vector = Factory.Vector(9, 2)
Example using a class name:
>>> from kivy.factory import Factory
>>> Factory.register('MyWidget', cls=MyWidget)
- kivy.factory.Factory = <kivy.factory.FactoryBase object at 0x10bf950>¶
Factory instance to use for getting new classes