Source#
A base class for data source implementations.
Usage#
Data sources are abstractions that allow you to define the data being managed by your application independent of the GUI representation of that data. For details on the use of data sources, see the background guide.
Source isn’t useful on its own; it is a base class for data source implementations. It is used by ListSource, TreeSource and ValueSource, but it can also be used by custom data source implementations. It provides an implementation of the notification API that data sources must provide.
Reference#
- class toga.sources.Listener(*args, **kwargs)#
Bases:
Protocol
The protocol that must be implemented by objects that will act as a listener on a data source.
- change(item)#
A change has occurred in an item.
- Parameters:
item – The data object that has changed.
- clear()#
All items have been removed from the data source.
- Parameters:
index – The 0-index position in the data.
item – The data object that was added.
- class toga.sources.Source#
A base class for data sources, providing an implementation of data notifications.
- add_listener(listener)#
Add a new listener to this data source.
If the listener is already registered on this data source, the request to add is ignored.
- Parameters:
listener (Listener) – The listener to add
- property listeners: list[Listener]#
The listeners of this data source.
- Returns:
A list of objects that are listening to this data source.