Posts: 544
Threads: 15
Joined: Oct 2016
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.
Posts: 544
Threads: 15
Joined: Oct 2016
You can also do this.
print(vars(color))
99 percent of computer problems exists between chair and keyboard.