Table Of Contents
Adapter¶
バージョン 1.5 で追加.
バージョン 1.10.0 で撤廃: The feature has been deprecated.
警告
This code is still experimental, and its API is subject to change in a future version.
An Adapter is a bridge between data and
an AbstractView or one of its subclasses, such
as a ListView.
The following arguments can be passed to the contructor to initialise the corresponding properties:
data: for any sort of data to be used in a view. For anAdapter, data can be an object as well as a list, dict, etc. For aListAdapter, data should be a list. For aDictAdapter, data should be a dict.cls: the class used to instantiate each list item view instance (Use this or the template argument).template: a kv template to use to instantiate each list item view instance (Use this or the cls argument).args_converter: a function used to transform the data items in preparation for either a cls instantiation or a kv template invocation. If no args_converter is provided, the data items are assumed to be simple strings.
Please refer to the adapters documentation for an overview of how
adapters are used.
-
class
kivy.adapters.adapter.Adapter(**kwargs)[ソース]¶ ベースクラス:
kivy.event.EventDispatcherAn
Adapteris a bridge between data and anAbstractViewor one of its subclasses, such as aListView.-
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_converteris anObjectPropertyand defaults to None.
-
cls¶ A class for instantiating a given view item (Use this or template). If this is not set and neither is the template, a
Labelis used for the view item.clsis anObjectPropertyand defaults to None.
-
data¶ The data for which a view is to be constructed using either the cls or template provided, together with the args_converter provided or the 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 it in order to use another data type, such as a
ListPropertyorDictPropertyas appropriate. For example, in aListAdapter, data is aListProperty.datais anObjectPropertyand defaults to None.
-
get_cls()[ソース]¶ バージョン 1.9.0 で追加.
Returns the widget type specified by self.cls. If it is a string, the
Factoryis queried to retrieve the widget class with the given name, otherwise it is returned directly.
-
template¶ A kv template for instantiating a given view item (Use this or cls).
templateis anObjectPropertyand defaults to None.
-