Skip to content
Snippets Groups Projects
Commit 4376f2a9 authored by Dolleans Geoffrey's avatar Dolleans Geoffrey
Browse files

tkinter 9/many on s'éloigne de tout succés

parent 2f51008a
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ from game_of_life.Affichage_universe import *
import random as rd
fenetre = Tk()
game_of_life = Toplevel(fenetre)
game_of_life = Toplevel(fenetre, width= 700, height=700)
game_of_life.grid()
canvas = Canvas(game_of_life)
canvas.pack()
......@@ -29,15 +29,10 @@ def create_a_grid():
zones.append([])
for y in range(len(universe[0])):
if universe[x][y]==1:
zones[x].append(canvas.create_rectangle(x*width/100,(x+1)*width/100,y*width/100,(y+1)*width/100), fill="black")
zones[x].append(canvas.create_rectangle(x*7,(x+1)*7,y*7,(y+1)*7), fill="black")
else:
zones[x].append(canvas.create_rectangle(x*width/100,(x+1)*width/100,y*width/100,(y+1)*width/100, fill="white"))
for x in range (len(universe)):
for y in range (len(universe[0])):
if universe[x][y]==1:
canvas.itemconfig(zones[x][y], fill="black")
else:
canvas.itemconfig(zones[x][y], fill="white")
zones[x].append(canvas.create_rectangle(x*7,(x+1)*7,y*7,(y+1)*7, fill="white"))
def update_grid():
......@@ -64,8 +59,8 @@ def update_grid():
def create_cell_on_click(event):
"""créer une cellule vivante la ou l'utilisateur clique"""
global universe
x = event.x//(game_of_life.winfo_width()/100)
y = event.y//(game_of_life.winfo_height()/100)
x = event.x//7
y = event.y//7
universe[x][y] = 1
def add_seed_tk():
......@@ -80,7 +75,6 @@ def add_seed_tk():
universe= add_seed_to_universe(seed, universe, x_start, y_start)
button_add_seed = Button(fenetre, text="ajoute la graine",command=add_seed_tk)
button_add_seed.pack()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment