Version

Quick search

Adapters

New in version 1.5.0.

Deprecated since version 1.10.0: The feature has been deprecated.

An adapter is a mediating controller-type class that processes and presents data for use in views. It does this by generating models, generally lists of SelectableView items, that are consumed and presented by views. Views are top-level widgets, such as a ListView, that allow users to scroll through and (optionally) interact with your data.

The Concept

Kivy adapters are modelled on the Adapter design pattern. Conceptually, they play the role of a ‘controller’ between you data and views in a Model-View-Controller type architecture.

The role of an adapter can be depicted as follows:

_images/adapters.png

The Components

The components involved in this process are:

  • Adapters: The adapter plays a mediating role between the user interface and your data. It manages the creation of the view elements for the model using the args_converter to prepare the contructor arguments for your cls/template view items.

    The base Adapter is subclassed by the SimpleListAdapter and ListAdapter. The DictAdapter is a more advanced and flexible subclass of ListAdapter.

  • Models: The data for which an adapter serves as a bridge to views can be any sort of data. However, for convenience, model mixin classes can ease the preparation or shaping of data for use in the system. For selection operations, the SelectableDataItem can optionally prepare data items to provide and receive selection information (data items are not required to be “selection-aware”, but in some cases it may be desired).

  • Args Converters: Argument converters are made by the application programmer to do the work of converting data items to argument dictionaries suitable for instantiating views. In effect, they take each row of your data and create dictionaries that are passed into the constructors of your cls/template which are then used populate your View.

  • Views: Models of your data are presented to the user via views. Each of your data items create a corresponding view subitem (the cls or template) presented in a list by the View. The base AbstractView currently has one concrete implementation: the ListView.