Skip to content

Label

A text label.

Label on macOS

Label on Linux (GTK)

Label on Linux (Qt)

Label on Windows

Label on iOS

Label on Android

Label on Web

Screenshot not available

Usage

import toga

label = toga.Label("Hello world")

Notes

  • Winforms does not support a text alignment value of JUSTIFIED. If this alignment value is used, the label will default to left alignment.

Reference

toga.Label

Label(text: str, id: str | None = None, style: StyleT | None = None, **kwargs)

Bases: Widget

Create a new text label.

PARAMETER DESCRIPTION
text

Text of the label.

TYPE: str

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

kwargs

Initial style properties.

DEFAULT: {}

text property writable

text: str

The text displayed by the label.

None, and the Unicode codepoint U+200B (ZERO WIDTH SPACE), will be interpreted and returned as an empty string. Any other object will be converted to a string using str().

focus

focus() -> None

No-op; Label cannot accept input focus.