Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from random import randint
- root = Tk()
- field = [[None] * 4 for i in range(4)]
- def add_tile(event):
- i = randint(0,3)
- j = randint(0,3)
- if not field[i][j]:
- field[i][j] = Label(root, text = "2", font = "Arial 48", bg="lightblue")
- field[i][j].grid(row = i, column = j)
- else:
- add_tile(event)
- root.bind("<Left>", add_tile)
- root.mainloop()
- [None, None, None, None]
- [None, None, None, None]
- [None, None, None, None]
- [None, None, None, None]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement