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: str | None = None, icon: IconContentT | None = None, id: str | None = None, style: StyleT | None = None, on_press: toga.widgets.button.OnPressHandler | None = None, enabled: bool = True, **kwargs)

Extends toga.Button with the feature to define the size of the icon.

from tatogalib.ui.tabutton import TaButton
button = TaButton("", on_press=self.button_pressed)
icon = toga.Icon(self.app.paths.app / "resources/50x50.png")
button.set_icon(icon, 30)

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][toga.icons.IconContentT].

  • 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.

  • kwargs – Initial style properties.

set_icon(icon, size=-1)

Sets the icon of the button

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

  • size (int) – The size in CSS pixels. When size is -1 or missing, the default size is used