Advertisement
snowden_web

Untitled

Aug 28th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. from tkinter import *
  2. from random import randint
  3.  
  4. root = Tk()
  5.  
  6. field = [[None] * 4 for i in range(4)]
  7.  
  8. def add_tile(event):
  9.     i = randint(0,3)
  10.     j = randint(0,3)
  11.     if not field[i][j]:
  12.         field[i][j] = Label(root, text = "2", font = "Arial 48", bg="lightblue")
  13.         field[i][j].grid(row = i, column = j)
  14.     else:
  15.         add_tile(event)
  16.        
  17. root.bind("<Left>", add_tile)
  18.  
  19. root.mainloop()
  20.  
  21.  
  22. [None, None, None, None]
  23. [None, None, None, None]
  24. [None, None, None, None]
  25. [None, None, None, None]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement