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 topic 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
toga.sources.Listener
Bases: Protocol
The protocol that must be implemented by objects that will act as a listener on a
data source.
change
A change has occurred in an item.
| PARAMETER |
DESCRIPTION |
item
|
The data object that has changed.
TYPE:
object
|
clear
All items have been removed from the data source.
insert
An item has been added to the data source.
| PARAMETER |
DESCRIPTION |
index
|
The 0-index position in the data.
TYPE:
int
|
item
|
The data object that was added.
TYPE:
object
|
remove
An item has been removed from the data source.
| PARAMETER |
DESCRIPTION |
index
|
The 0-index position in the data.
TYPE:
int
|
item
|
The data object that was added.
TYPE:
object
|
toga.sources.Source
A base class for data sources, providing an implementation of data
notifications.
listeners
property
The listeners of this data source.
| RETURNS |
DESCRIPTION |
list[Listener]
|
A list of objects that are listening to this data source.
|
add_listener
add_listener(listener: Listener) -> None
Add a new listener to this data source.
If the listener is already registered on this data source, the request to add is
ignored.
| PARAMETER |
DESCRIPTION |
listener
|
TYPE:
Listener
|
notify
notify(notification: str, **kwargs: object) -> None
Notify all listeners an event has occurred.
| PARAMETER |
DESCRIPTION |
notification
|
The notification to emit.
TYPE:
str
|
kwargs
|
The data associated with the notification.
TYPE:
object
DEFAULT:
{}
|
remove_listener
remove_listener(listener: Listener) -> None
Remove a listener from this data source.
| PARAMETER |
DESCRIPTION |
listener
|
TYPE:
Listener
|