I'm recreating wordle and I want the keyboard to be on the screen. I know about the keyboardlayouts library but I couldn't make it do what I needed. Instead, I created a list of dicts( self.keys = [ {"value": "Q", "rect" : (330, 450, 46, 60), "parameters" : (353, 480)}...]) and a function that iterates over them and prints them all:
def get_keyboard(self, color=(211,214,218), text_color="Black"):
for key in self.keys:
pygame.draw.rect(self.screen, color, pygame.Rect(key["rect"]), border_radius=4)
text = self.font.render(f'{key["value"]}', True, text_color)
text_rect = text.get_rect(center=key["parameters"])
self.screen.blit(text, text_rect)```
however, the way the whole thing looks makes me think there might be a better way to do that, but this is the best I could come up with considering the rows don't have any pattern as to where they start. Thoughts? Does the list look over-repetetive and possibly unnecessary?