adafruit / Adafruit_CircuitPython_DisplayIO_Layout

A Circuitpython helper library for display element layout using displayio.
MIT License
10 stars 14 forks source link

Provide a way to lookup elements by x,y grid position in GridLayout #43

Closed FoamyGuy closed 3 years ago

FoamyGuy commented 3 years ago

Currently the sub-elements within a GridLayout can be accessed by index of the order that they were added:

my_grid_layout[0]

Will return the first element that was added to the grid so that you can access it's properties i.e.

my_grid_layout[0].color = 0xFFFFFF

would change the font color of a Label that was the first item added.

It would be great to provide an alternate way to lookup the elements in the grid based on their x,y cell location so that you could do something like:

my_grid_layout.get_element(0,0).color = 0xFFFFFF

and it would give you back the element in the first row / column without needing to worry about the order that the elements were added in.