Skip to content

Divider

A visual layout separator.

Divider on macOS

Divider on Linux (GTK)

Divider on Linux (Qt)

Divider on Windows

Divider on iOS

Divider on Android

Screenshot not available

Not supported

Usage

A Divider can be used to distinguish two sections of content in a layout.

To separate two labels stacked vertically with a horizontal line:

import toga
from toga.style.pack import Pack, COLUMN

box = toga.Box(
    children=[
        toga.Label("First section"),
        toga.Divider(),
        toga.Label("Second section"),
    ],
    direction=COLUMN,
    flex=1,
    margin=10
)

The direction (horizontal or vertical) can be given as an argument. If not specified, it will default to horizontal.

Reference

toga.Divider

Divider(
    id: str | None = None,
    style: StyleT | None = None,
    direction: Direction = HORIZONTAL,
    **kwargs,
)

Bases: Widget

Create a new divider line.

PARAMETER DESCRIPTION
id

The ID for the widget.

TYPE: str | None DEFAULT: None

style

A style object. If no style is provided, a default style will be applied to the widget.

TYPE: StyleT | None DEFAULT: None

direction

The direction in which the divider will be drawn. Either Direction.HORIZONTAL or Direction.VERTICAL; defaults to Direction.HORIZONTAL

TYPE: Direction DEFAULT: HORIZONTAL

kwargs

Initial style properties.

DEFAULT: {}

direction property writable

direction: Direction

The direction in which the visual separator will be drawn.

enabled property writable

enabled: Literal[True]

Is the widget currently enabled? i.e., can the user interact with the widget?

Divider widgets cannot be disabled; this property will always return True; any attempt to modify it will be ignored.

focus

focus() -> None

No-op; Divider cannot accept input focus.