/usr/share/pyshared/kivy/adapters/models.py is in python-kivy 1.7.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | '''
SelectableDataItem
==================
.. versionadded:: 1.5
.. warning::
This code is still experimental, and its API is subject to change in a
future version.
Data Models
-----------
Kivy is open about the type of data used in applications built with
the system. However, base classes are optionally needed to conform data to
requirements of some parts of the system.
:class:`SelectableDataItem` is a basic Python data model class that can be
used as a mixin to build data objects that are compatible with Kivy's adapter
and selection system, which works with views such as ListView. The boolean
property is_selected is the requirement.
The default operation of the selection system is to not propogate selection in
views such as ListView to the underlying data -- selection is by default a
view-only operation. However, in some cases, it is useful to propogate
selection to the actual data items.
You may, of course, build your own Python data model system as the backend for
a Kivy application. For instance, to use the Google App Engine datamodeling
system with Kivy, this class could be redefined as::
from google.appengine.ext import db
class MySelectableDataItem(db.Model):
... other properties
is_selected = db.BooleanProperty()
It is easy to build such a class with plain Python, also.
'''
__all__ = ('SelectableDataItem', )
class SelectableDataItem(object):
'''
A mixin class containing requirements for selection operations.
This is the is_selected boolean.
'''
def __init__(self, **kwargs):
super(SelectableDataItem, self).__init__()
self._is_selected = kwargs.get('is_selected', False)
@property
def is_selected(self):
"""Is the data item selected"""
return self._is_selected
@is_selected.setter
def is_selected(self, value):
self._is_selected = value
|