Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. import tkinter as tk
  2.  
  3. root = tk.Tk()
  4. root.geometry('450x285+300+300')
  5. root.resizable(False, False)
  6.  
  7. spisok = [15, 16, 17, 14, 43, 53, 33, 95, 96, 97, 58, 57, 5, 6, 99, 98, 80, 36, 11, 18]
  8.  
  9. class TagButton(tk.Button):
  10.     def __init__(self, master, tag=None, *args, **kwargs):
  11.         tk.Button.__init__(self, master, *args, **kwargs)
  12.         self.tag = tag
  13.  
  14.  
  15. def click(event):
  16.     if event.widget.tag in spisok:
  17.         event.widget.configure(bg="red")
  18.     else:
  19.         event.widget.configure(bg="gray")
  20.  
  21.  
  22. for i in range(11):
  23.     for j in range(10):
  24.         b1 = TagButton(root, width=5, height=1, bg="blue", fg="black", tag=(i * j + j))
  25.         b1.grid(row=i, column=j)
  26.         b1.bind('<Button-1>', click)
  27.  
  28.  
  29. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement