Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- board = [
- ["parking", "red", "?", "red", "red", "blank", "yellow", "yellow", "water", "yellow", "go to jail"],
- ["orange", None, None, None, None, None, None, None, None, None, "green"],
- ["orange", None, None, None, None, None, None, None, None, None, "green"],
- ["chest", None, None, None, None, None, None, None, None, None, "chest"],
- ["orange", None, None, None, None, None, None, None, None, None, "green"],
- ["blank", None, None, None, None, None, None, None, None, None, "blank"],
- ["pink", None, None, None, None, None, None, None, None, None, "?"],
- ["pink", None, None, None, None, None, None, None, None, None, "blue"],
- ["electricity", None, None, None, None, None, None, None, None, None, "blank"],
- ["pink", None, None, None, None, None, None, None, None, None, "blue"],
- ["jail", "blue", "blue", "?", "blue", "blank", "blank", "purple", "chest", "purple", "go"]
- ]
- root = tk.Tk()
- def on_click(i,j,event):
- event.widget.config(bg=color)
- counter += 1
- for i,row in enumerate(board):
- for j,column in enumerate(row):
- board_element = board[i][j]
- if(board_element == "parking" or board_element == "blank" or board_element == "go to jail" or board_element == "parking" or board_element == "chest" or board_element == "?" or board_element == "water" or board_element == "electricity" or board_element == "jail" or board_element == "go"):
- color = "white"
- elif(board_element == None):
- color = "grey"
- else:
- color = board_element
- # if(j==0 or j==len(board[i])-1): # if on first or last column
- # if(i==0 or i==len(board)-1): # if on first or last row
- # width = 10
- # height = 5
- # else:
- # width = 20
- # height = 5
- # else:
- # width = 10
- # height = 5
- width = 10
- height = 5
- L = tk.Label(root,text=board[i][j],bg=color, height=height, width=width)
- L.grid(row=i,column=j)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement