TimelineProvider

class widgets.TimelineProvider

A timeline providers allows a script to provide content to a widget for the future.

Pass a subclass of TimelineProvider to provide_timeline() to provide a timeline of widgets. Calling this function in app will just preview the widget and will not have any effect.

reload_time() → datetime.timedelta | float

Returns the delay after which the widget should reload and run the script again. The return value is the delay between the last timeline entry and the next reload. The system doesn’t guarantees the widget to be reloaded at an exact time.

Supported return types are a float representing seconds or a datetime.timedelta object.

Return type:

Union[datetime.timedelta, float]

timeline() → List[datetime.datetime]

Returns a list of timestamps for which the script has data. Make sure to not provide an exaggerated ammount of dates because the widget can crash due to memory issues.

Return type:

List[datetime.datetime]

widget(date: datetime.datetime) → widgets.Widget

Returns a widget for the given timestamp.

Parameters:

date – The timestamp for which the widget is requested.

Return type:

Widget