Skip to content

List index out of range #65

Closed
Closed
@makermelissa

Description

@makermelissa

It turns out the issue with skipping the glyphs with zero-length tilegrids results in a List index out of range error:

Traceback (most recent call last):
  File "electioncal.py", line 58, in <module>
    gfx.elections_cycle()
  File "/home/pi/electioncal_graphics.py", line 86, in elections_cycle
    self.election_name_text_line2.text, self.election_name_text.text = self.paragrapher(self.electioncal["dates"][i]["name"], 40)
  File "/home/pi/.local/lib/python3.7/site-packages/adafruit_display_text/label.py", line 362, in text
    self._update_text(str(new_text))
  File "/home/pi/.local/lib/python3.7/site-packages/adafruit_display_text/label.py", line 292, in _update_text
    self[i].position = (position_x, position_y)
  File "/home/pi/.local/lib/python3.7/site-packages/displayio/group.py", line 142, in __getitem__
    return self._layers[index]
IndexError: list index out of range

Perhaps a better solution would be to check the width and height of the glyph and if zero, just substitute a 1. That essentially how I was doing it as a work-around, though it's possible that may cause text alignment issues. Another option may be just putting a None in there for face as an empty placeholder and checking for that when the text is rendered.

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