Skip to content

Index out of range error for label, sometimes... #5

Closed
@jpecor

Description

@jpecor

I am getting an index out of range error from the button_3 code in the example:

button_3 = Button(x=BUTTON_MARGIN*3+2*BUTTON_WIDTH, y=BUTTON_MARGIN*2+BUTTON_HEIGHT, width=BUTTON_WIDTH, height=BUTTON_HEIGHT, label="button3", label_font=font, label_color=0x0000FF, fill_color=None, outline_color=None) buttons.append(button_3)

Here's the error:

Traceback (most recent call last): File "code.py", line 71, in <module> File "adafruit_button.py", line 127, in __init__ File "adafruit_button.py", line 140, in label IndexError: Group index out of range

After tinkering a bit with the code, I found that if I pass in a value for EITHER the fill_color OR outline_color, it works. So, for example, this works:

button_3 = Button(x=BUTTON_MARGIN*3+2*BUTTON_WIDTH, y=BUTTON_MARGIN*2+BUTTON_HEIGHT, width=BUTTON_WIDTH, height=BUTTON_HEIGHT, label="button3", label_font=font, label_color=0x0000FF, fill_color=0x00FF00, outline_color=None) buttons.append(button_3)

IMG_8025

I have not dug into this any deeper, yet, but wanted to post the issue in case it's more obvious to someone else.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions