UI Buttons for displayio

  • Author(s): Limor Fried

Implementation Notes

Software and Dependencies:

class adafruit_button.Button(*, x, y, width, height, name=None, style=0, fill_color=16777215, outline_color=0, label=None, label_font=None, label_color=0, selected_fill=None, selected_outline=None, selected_label=None)

Helper class for creating UI buttons for displayio.

  • x – The x position of the button.
  • y – The y position of the button.
  • width – The width of the button in pixels.
  • height – The height of the button in pixels.
  • name – The name of the button.
  • style – The style of the button. Can be RECT, ROUNDRECT, SHADOWRECT, SHADOWROUNDRECT. Defaults to RECT.
  • fill_color – The color to fill the button. Defaults to 0xFFFFFF.
  • outline_color – The color of the outline of the button.
  • label – The text that appears inside the button. Defaults to not displaying the label.
  • label_font – The button label font.
  • label_color – The color of the button label text. Defaults to 0x0.
  • selected_fill – Inverts the fill color.
  • selected_outline – Inverts the outline color.
  • selected_label – Inverts the label color.

Used to determine if a point is contained within a button. For example, button.contains(touch) where touch is the touch point on the screen will allow for determining that a button has been touched.


Return self for compatibility with old API.


The text label of the button


Selected inverts the colors.