from tkinter import * import numpy as np master = Tk() master.title("master GUI") # Add a title ##master.withdraw() child = Toplevel(master,width=200,height=100) child.title("child GUI") def callback(gg,bg): print(gg) print(bg) hhy = Button(child, width=12, height=1, text=gg, bg=bg) hhy.pack(fill = X) class Person: def __init__(self, gg,bg,pp,ee): self.gg = gg self.bg = bg gt=bg ggx = Button(master, width=12, height=1, text=gg, bg=bg, command=lambda:callback(gg,bg)) ggx.grid(column=pp,row=ee) from itertools import cycle from itertools import repeat suit = ['Diamonds', 'Spades', 'Clubs', 'Hearts'] color = ['blue', 'red', 'green', 'yellow'] column = np.arange(13) # 0 through 12 column = np.repeat(column, 4) row = np.arange(1, 5) # 1 through 5 rank = np.array(['A', 'K', 'Q', 'J', '10', '9', '8', '7', '6', '5', '4', '3', '2']) rank = np.repeat(rank, 4) for r, s, c, row_, column_ in zip(rank, cycle(suit), cycle(color), cycle(row), column): Person('{} {}'.format(r, s), c, int(row_),int(column_)) mainloop()