Sep-23-2019, 10:27 PM
Is this what you are talking about.
import pygame class PygameColors: def __init__(self): self.__dict__.update(pygame.color.THECOLORS) def __getitem__(self, key): return self.__dict__[key] def add(self, name, r, g, b, a=255): if name not in vars(self).keys(): setattr(self, name, pygame.Color(r, g, b, a)) else: print("Color already exists:", name) color = PygameColors() print("white:", color["white"], color.white, pygame.Color("white"))
99 percent of computer problems exists between chair and keyboard.