Skip to content

DISPIO: classes not maintining thier subclasses once added to group #1551

@TG-Techie

Description

@TG-Techie
from board import DISPLAY
import displayio, time
class rect(displayio.TileGrid):
    
    def __init__(self, x, y, width, height, color):
        
        self.plt = displayio.Palette(2)
        self.plt.make_transparent(0)
        self.color = color
        
        super().__init__(displayio.Shape(width, height), pixel_shader = self.plt, position = (x,y))
        
        
    @property
    def color(self):
        return self.plt[1]
    
    @color.setter
    def color(self, valin):
        self.plt[1] = valin
    
    @property
    def x(self):
        return self.position[0]
    
    @property
    def y(self):
        return self.position[1]
    
    @x.setter
    def x(self, valin):
        self.position = (valin, self.position[1])
        
    @x.setter
    def y(self, valin):
        self.position = (self.position[0], valin)


grp = displayio.Group(max_size = 1)
r = rect(5,5,50,30,0xffffff)
print(type(r))
grp.append(r)
print(type(r))
DISPLAY.show(grp)
time.sleep(1)
print(type(grp[0]))

gives:
<class 'rect'>
<class 'rect'>
<class 'TileGrid'>

this means my rect class cannot edit the palette inside of it.

CircuitPython 4.0.0-beta.2-58-g35e3d99f6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions