Divider¶
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¶
Bases: Widget
Source code in core/src/toga/widgets/divider.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
direction
property
writable
¶
The direction in which the visual separator will be drawn.
enabled
property
writable
¶
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.
__init__(id=None, style=None, direction=HORIZONTAL, **kwargs)
¶
Create a new divider line.
:param id: The ID for the widget.
:param style: A style object. If no style is provided, a default style will be
applied to the widget.
:param direction: The direction in which the divider will be drawn. Either
Direction.HORIZONTAL or
Direction.VERTICAL; defaults to
Direction.HORIZONTAL
:param kwargs: Initial style properties.
Source code in core/src/toga/widgets/divider.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
focus()
¶
No-op; Divider cannot accept input focus.
Source code in core/src/toga/widgets/divider.py
52 53 54 | |