Functions

This page contains a list of functions defined in the widgets module.

widgets.schedule_next_reload(time: Union[datetime.timedelta, float])

Schedules the next reload of the widget. The widget may not be reloaded exactly at the provided time, the system will choose when it’s appropiate but never before the provided time.

Parameters:time – The time passed before the widget should reload. A datetime.timedelta object or the number of seconds.
widgets.wait_for_internet_connection()
widgets.delete_in_app_widget(key: str)

Deletes a widget saved with save_widget() or save_snapshot().

Parameters:key – The name of the widget.
widgets.reload_widgets(names: Union[str, List[str]])

Reloads the widgets corresponding to the given scripts names. It works only for “Run Script” widgets.

The names can and can also not contain the “.py” suffix.

Parameters:names – A string or a list of strings corresponding to the scripts to reload as widgets.

Showing a native UI

widgets.show_widget(widget: widgets.Widget)

Shows a widget with the given configuration

Parameters:widget – The widget’s configuration.
widgets.provide_timeline(provider: widgets.TimelineProvider)

Provides a timeline of widgets for the future.

Parameters:provider – A TimelineProvider subclass.
widgets.save_widget(widget: widgets.Widget, key: str)

Saves a widget that will be selectable to show in a widget and can be updated in app.

Parameters:
  • widget – The widget’s configuration.
  • key – The name of the widget. When a new widget is saved with an existing key, it will be updated.

Showing a PytoUI view

widgets.show_view(view: widgets.PytoUIView)

Shows the given view on a widget. A snapshot for each widget size will be taken.

Parameters:view – A view to show in the widget.
widgets.save_snapshot(view: widgets.PytoUIView, key: str)

Saves the snapshot of the given view. The snapshot will be selectable to show in a widget and can be updated in app.

Parameters:
  • view – A view to show in the widget.
  • key – The name of the snapshot. When a new snapshot is saved with an existing key, the widget will be updated.