Advertisement
PabiGamito

Monopoly UI

Apr 26th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.19 KB | None | 0 0
  1. import tkinter as tk
  2.  
  3. board = [
  4.             ["parking", "red", "?", "red", "red", "blank", "yellow", "yellow", "water", "yellow", "go to jail"],
  5.             ["orange", None, None, None, None, None, None, None, None, None, "green"],
  6.             ["orange", None, None, None, None, None, None, None, None, None, "green"],
  7.             ["chest", None, None, None, None, None, None, None, None, None, "chest"],
  8.             ["orange", None, None, None, None, None, None, None, None, None, "green"],
  9.             ["blank", None, None, None, None, None, None, None, None, None, "blank"],
  10.             ["pink", None, None, None, None, None, None, None, None, None, "?"],
  11.             ["pink", None, None, None, None, None, None, None, None, None, "blue"],
  12.             ["electricity", None, None, None, None, None, None, None, None, None, "blank"],
  13.             ["pink", None, None, None, None, None, None, None, None, None, "blue"],
  14.             ["jail", "blue", "blue", "?", "blue", "blank", "blank", "purple", "chest", "purple", "go"]
  15.         ]
  16.  
  17. root = tk.Tk()
  18.  
  19. def on_click(i,j,event):
  20.     event.widget.config(bg=color)
  21.     counter += 1
  22.  
  23.  
  24. for i,row in enumerate(board):
  25.     for j,column in enumerate(row):
  26.  
  27.         board_element = board[i][j]
  28.  
  29.         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"):
  30.             color = "white"
  31.         elif(board_element == None):
  32.             color = "grey"
  33.         else:
  34.             color = board_element
  35.  
  36.         # if(j==0 or j==len(board[i])-1): # if on first or last column
  37.         #     if(i==0 or i==len(board)-1): # if on first or last row
  38.         #         width = 10
  39.         #         height = 5
  40.         #     else:
  41.         #         width = 20
  42.         #         height = 5
  43.         # else:
  44.         #     width = 10
  45.         #     height = 5
  46.  
  47.  
  48.         width = 10
  49.         height = 5
  50.  
  51.         L = tk.Label(root,text=board[i][j],bg=color, height=height, width=width)
  52.         L.grid(row=i,column=j)
  53.  
  54.  
  55. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement