tabutton package

This package is a plug-in replacement for toga.Button which allows to use Icons with a user-defined size. The default size is 48x48 for Android and 32x32 for Winforms (CSS pixels).

To specify a different size, create a TaButton with text=None and then use the TaButton.set_icon(icon, size) method.

TaButton class

class tatogalib.ui.tabutton.TaButton(text=None, icon=None, id=None, style=None, on_press=None, enabled: bool = True)

Create a new button widget.

Parameters:
  • text – The text to display on the button.

  • icon – The icon to display on the button. Can be specified as any valid icon content.

  • id – The ID for the widget.

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

  • on_press – A handler that will be invoked when the button is pressed.

  • enabled – Is the button enabled (i.e., can it be pressed?). Optional; by default, buttons are created in an enabled state.

property icon

The icon displayed on the button.

Can be specified as any valid icon content.

If the button is currently displaying text, and an icon is assigned, the text will be replaced by the new icon.

If None is assigned as an icon, the button will become a text button with an empty label.

Returns None if the button is currently displaying text.

property on_press: OnPressHandler

The handler to invoke when the button is pressed.

set_icon(icon, size)

Sets the icon of the button

Parameters:
  • icon – The icon to display on the button. Can be specified as any valid icon content.

  • size (int) – The size in CSS pixels

property text: str

The text displayed on the button.

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().

Only one line of text can be displayed. Any content after the first newline will be ignored.

If the button is currently displaying an icon, and text is assigned, the icon will be replaced by the new text.

If the button is currently displaying an icon, the empty string will be returned.