Skip to content
Toga
0.5.3.dev143+gabcc6cdb6

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

change(item)

A change has occurred in an item.

PARAMETER DESCRIPTION
item

The data object that has changed.

TYPE: object

clear

clear()

All items have been removed from the data source.

insert

insert(index, item)

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

remove(index, item)

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

Source()

A base class for data sources, providing an implementation of data notifications.

listeners property

listeners

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)

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

The listener to add

TYPE: Listener

notify

notify(notification, **kwargs)

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)

Remove a listener from this data source.

PARAMETER DESCRIPTION
listener

The listener to remove.

TYPE: Listener