Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- root = tk.Tk()
- root.geometry('450x285+300+300')
- root.resizable(False, False)
- spisok = [15, 16, 17, 14, 43, 53, 33, 95, 96, 97, 58, 57, 5, 6, 99, 98, 80, 36, 11, 18]
- class TagButton(tk.Button):
- def __init__(self, master, tag=None, *args, **kwargs):
- tk.Button.__init__(self, master, *args, **kwargs)
- self.tag = tag
- def click(event):
- if event.widget.tag in spisok:
- event.widget.configure(bg="red")
- else:
- event.widget.configure(bg="gray")
- for i in range(11):
- for j in range(10):
- b1 = TagButton(root, width=5, height=1, bg="blue", fg="black", tag=(i * j + j))
- b1.grid(row=i, column=j)
- b1.bind('<Button-1>', click)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement