Skip to content
Snippets Groups Projects
Commit 1faf1cea authored by Thomas Bianco's avatar Thomas Bianco
Browse files

grille initiale

parent 9f9aa5e6
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,8 @@
<option value="E501" />
<option value="W29" />
<option value="E501" />
<option value="W29" />
<option value="E501" />
</list>
</option>
</inspection_tool>
......
import tkinter as tk
from tkinter import *
from run_2048 import *
THEMES = {"0": {"name": "Default", 0: "", 2: "2", 4: "4", 8: "8", 16: "16", 32:"32", 64: "64", 128: "128", 256: "256", 512: "512", 1024: "1024", 2048: "2048",4096: "4096", 8192: "8192"}, "1": {"name": "Chemistry", 0: "", 2: "H", 4: "He", 8:"Li", 16: "Be", 32: "B", 64: "C", 128: "N", 256: "O", 512: "F", 1024: "Ne", 2048:"Na", 4096: "Mg", 8192: "Al"}, "2": {"name": "Alphabet", 0: "", 2: "A", 4: "B", 8:"C", 16: "D", 32: "E", 64: "F", 128: "G", 256: "H", 512: "I", 1024: "J", 2048: "K",4096: "L", 8192: "M"}}
TILES_BG_COLOR = {0: "#9e948a", 2: "#eee4da", 4: "#ede0c8", 8: "#f1b078", \
16: "#eb8c52", 32: "#f67c5f", 64: "#f65e3b", \
128: "#edcf72", 256: "#edcc61", 512: "#edc850", \
......@@ -14,24 +16,34 @@ TILES_FG_COLOR = {0: "#776e65", 2: "#776e65", 4: "#776e65", 8: "#f9f6f2", \
TILES_FONT = {"Verdana", 40, "bold"}
def main_run():
def graphical_grid_init():
root = tk.Tk()
window = tk.Toplevel()
grid_game = init_game()
root = Tk()
background = Frame(root)
grid_size = 4
background = tk.Frame(root)
theme = THEMES["0"]
graphical_grid = []
labels = []
game_grid = init_game(grid_size)
for i in range(grid_size):
graphical_grid.append([])
labels.append([])
for j in range(grid_size):
graphical_grid[i].append(tk.Frame(master = background, bd = 2,relief = "raised", bg = TILES_BG_COLOR[0],height = 100, width = 100))
graphical_grid[i].append(Label(master = background, bd = 1,relief = "ridge", bg = TILES_BG_COLOR[0], text = "",height = 5, width = 10))
graphical_grid[i][j].grid(column = i, row = j)
graphical_grid = graphical_update(graphical_grid,game_grid,grid_size,theme)
background.pack()
root.mainloop()
graphical_grid_init()
def graphical_update(graphical_grid,game_grid,grid_size,theme):
for i in range(grid_size):
for j in range(grid_size):
graphical_grid[i][j].config(bg = TILES_BG_COLOR[game_grid[i][j]], fg = TILES_FG_COLOR[game_grid[i][j]], text = theme[game_grid[i][j]])
return graphical_grid
main_run()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment