Sep-24-2019, 05:19 AM
(Sep-23-2019, 10:27 PM)Windspar Wrote: Is this what you are talking about.
I meant contents of the inbuilt color dictionary. Adding function colordict(), to the code provided by you, has met this requirement, as placed below:
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) def colordict(self): return self.__dict__ color = PygameColors() print(color.colordict())
A.D.Tejpal