Quick search

Table Of Contents

Adapter

New in version 1.5.

Warning

This code is still experimental, and its API is subject to change in a future version.

Adapter is a bridge between data and AbstractView or one of its subclasses, such as ListView.

Arguments:

  • data, for any sort of data to be used in a view. In Adapter, data can be an object, as well as a list, dict, etc. For ListAdapter, data is a list, and for DictAdapter, it is a dict.
  • cls, for a list key class to use to instantiate list item view instances (Use this or the template argument)
  • template, a kv template to use to instantiate list item view instances (Use this or the cls argument)
  • args_converter, a function to transform data item argument sets, in preparation for either a cls instantiation, or a kv template invocation. If no args_converter is provided, a default one, that assumes that the data items are strings, is used.
class kivy.adapters.adapter.Adapter(**kwargs)

Bases: kivy.event.EventDispatcher

Adapter is a bridge between data and AbstractView or one of its subclasses, such as ListView.

args_converter

A function that prepares an args dict for the cls or kv template to build a view from a data item.

If an args_converter is not provided, a default one is set that assumes simple content in the form of a list of strings.

args_converter is an ObjectProperty, default to None.

cls

A class for instantiating a given view item. (Use this or template).

cls is an ObjectProperty, default to None.

data

The data for which a view is to be constructed using either the cls or template provided, using an args_converter provided or a default args converter.

In this base class, data is an ObjectProperty, so it could be used for a wide variety of single-view needs.

Subclasses may override to another data type, such as ListProperty or ListProperty.

data is an ObjectProperty, default to None.

template

A kv template for instantiating a given view item. (Use this or cls).

template is an ObjectProperty, default to None.