WidgetLayout

class widgets.WidgetLayout

The layout of a widget with all its UI elements. A Widget contains 3 layouts: small, medium and large. A widget layout is composed of rows, each row containing a list of UI elements.

add_row(row, background_color: widgets.Color = None, corner_radius: float = 0.0, link: str = None)

Adds a row to the widget layout. A row is a list of UI elements on the same horizontal line.

Parameters:
  • row – A list of UI elements.

  • background_color – The background color of the row.

  • corner_radius – The radius to use when drawing rounded corners for the row’s background.

  • link – A string that will be passed to the widget script when the row is tapped. This parameter doesn’t take effect on small widgets.

add_vertical_divider(color: widgets.Color = None)

Adds a visual vertical separator.

Parameters:

color – The color of the line.

add_vertical_spacer()

Adds a row that takes as much as vertical space as possible.

set_background_color(color: widgets.Color)

Sets the background color of the widget layout.

Parameters:

color – A Color object.

set_background_gradient(colors)

Sets the background color of the widget layout to a gradient. The gradient is linear and goes from top to bottom and uses the colors passed as a list.

Parameters:

colors – A list of Color objects for the gradient.

set_background_image(image)

Sets the background image of the widget layout.

Parameters:

image – An Image object.

When a widget is tapped, the widget is executed in app and the link attribute is passed to link.

Links on entire widgets take effect on small widgets unlike links on UI elements.

Parameters:

link – A string that will be passed to the widget script when the widget is tapped.