# Group – Group together sprites and subgroups¶

Manage a group of sprites and groups and how they are inter-related.

class displayio.Group(*, max_size=4, scale=1, x=0, y=0)

Create a Group of a given size and scale. Scale is in one dimension. For example, scale=2 leads to a layer’s pixel being 2x2 pixels when in the group.

Parameters: max_size (int) – The maximum group size. scale (int) – Scale of layer pixels in one dimension. x (int) – Initial x position within the parent. y (int) – Initial y position within the parent.
hidden

True when the Group and all of it’s layers are not visible. When False, the Group’s layers are visible if they haven’t been hidden.

scale

Scales each pixel within the Group in both directions. For example, when scale=2 each pixel will be represented by 2x2 pixels.

x

X position of the Group in the parent.

y

Y position of the Group in the parent.

append(layer)

Append a layer to the group. It will be drawn above other layers.

insert(index, layer)

Insert a layer into the group.

index(layer)

Returns the index of the first copy of layer. Raises ValueError if not found.

pop(i=-1)

Remove the ith item and return it.

remove(layer)

Remove the first copy of layer. Raises ValueError if it is not present.

__len__()

Returns the number of layers in a Group

__getitem__(index)

Returns the value at the given index.

This allows you to:

print(group[0])

__setitem__(index, value)

Sets the value at the given index.

This allows you to:

group[0] = sprite

__delitem__(index)

Deletes the value at the given index.

This allows you to:

del group[0]