Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1. from tkinter import *
  2. global start
  3. start = False
  4.  
  5.  
  6.  
  7. def rect():
  8.     x = 0
  9.     x1 = 10
  10.     y = 0
  11.     y1 = 10
  12.     tag = '1'
  13.    
  14.     def binder(x, x1, y, y1, tag):
  15.         c.create_rectangle(x,y,x1,y1,tag = tag, fill='white')
  16.         c.tag_bind(tag,'<Button-1>',lambda event: c.itemconfig(tag,c.itemconfig('group1',fill='red',width=3),fill='red',width=3))  
  17.        
  18.        
  19.     while x1 != 1450 and y1 != 910:
  20.         binder(x, x1, y, y1, tag)
  21.         x = x + 10
  22.         x1 = x1 + 10
  23.         tag = str(int(tag) + 1)
  24.         if x1 == 1450:
  25.             x = 0
  26.             x1 = 10
  27.             y = y + 10
  28.             y1 = y1 + 10
  29.    
  30.  
  31. def start_game():
  32.     global c
  33.     c = Canvas(w,width = 1450,height = 910)
  34.     c.pack()
  35.     button = Button(w,width = 12,height = 2,text = 'Выход',bg = 'red',fg = 'black',command = lambda: w.destroy())
  36.     button.place(x = 0,y = 0)
  37.     rect()
  38.  
  39. def main():
  40.     global w
  41.     w = Tk()
  42.     w.attributes('-fullscreen',True)
  43.     button = Button(w,width = 12,height = 2,text = 'Выход',bg = 'red',fg = 'black',command = lambda: w.destroy())
  44.     button.place(x = 0,y = 0)
  45.     button1 = Button(w,width = 12,height = 2,text = 'Начать',bg = 'red',fg = 'black',command = lambda: start_game())
  46.     button1.place(x = 500,y = 500)
  47.     w.mainloop()
  48. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement