@ -1,17 +1,22 @@
import tkinter as tk
from tkinter import *
from copy import deepcopy
from time import sleep
lst_c = [ ]
lst_grille = [ ]
f_cont = [ ]
########Fonction interface utilisateur###########
def bouton_grille ( ) :
global nb_ligne
global nb_colonne
nb_ligne = nb_ligne_choisi . get ( )
nb_colonne = nb_colonne_choisi . get ( )
creer_grille ( )
def creer_grille ( ) :
global grille
global lst_grille
global nb_ligne , nb_colonne
##############création_grille##########
nb_ligne = nb_ligne_choisi . get ( )
nb_colonne = nb_colonne_choisi . get ( )
grille = [ ]
lst_grille = [ ]
for ligne in range ( 0 , nb_ligne ) :
@ -124,7 +129,7 @@ def save():
state . write ( str ( grille [ ligne ] [ col ] ) + " " )
def load ( ) :
global grille
new_state = open ( tk . filedialog . askopenfilename ( initialdir = " /mathis.philippot/Document /" , title = " Choisir un fichier " , filetypes = ( ( " Text files " , " *.txt* " ) , ) ) , " r " )
new_state = open ( filedialog . askopenfilename ( initialdir = " / " , title = " Choisir un fichier " , filetypes = ( ( " Text files " , " *.txt* " ) , ) ) , " r " )
new_state = new_state . readline ( )
new_state = new_state . split ( " , " )
for chiffre_l in range ( 0 , len ( new_state ) ) :
@ -136,42 +141,42 @@ def load():
creer_care ( len ( new_state ) , len ( new_state [ 0 ] ) )
##########Programme principale##############
fenetre = tk . Tk ( )
fenetre = Tk ( )
fenetre . title ( " Jeu Amoa " )
zone = tk . Canvas ( fenetre , height = 795 , width = 1246 , bg = " #ffffff " )
zone = Canvas ( fenetre , height = 795 , width = 1246 , bg = " #ffffff " )
zone . grid ( row = 1 , column = 2 , rowspan = 9 )
##################Grille####################
nb_ligne_choisi = tk . IntVar ( )
mess_ligne = tk . Label ( text = " Nombre de ligne choisi " )
nb_ligne_choisi = IntVar ( )
mess_ligne = Label ( text = " Nombre de ligne choisi " )
mess_ligne . grid ( row = 1 , column = 1 )
choix_l = tk . Entry ( textvariable = nb_ligne_choisi , bd = 5 )
choix_l = Entry ( textvariable = nb_ligne_choisi , bd = 5 )
choix_l . grid ( row = 2 , column = 1 )
nb_colonne_choisi = tk . IntVar ( )
mess_col = tk . Label ( text = " Nombre de colone choisi " )
nb_colonne_choisi = IntVar ( )
mess_col = Label ( text = " Nombre de colone choisi " )
mess_col . grid ( row = 3 , column = 1 )
choix_col = tk . Entry ( textvariable = nb_colonne_choisi , bd = 5 )
choix_col = Entry ( textvariable = nb_colonne_choisi , bd = 5 )
choix_col . grid ( row = 4 , column = 1 )
bout_g = tk . Button ( text = " Créer la grille " , command = creer _grille)
bout_g = Button ( text = " Créer la grille " , command = bouton _grille)
bout_g . grid ( row = 5 , column = 1 )
################Génération##################
suivant = tk . Button ( text = " Prochaine génération " , command = gen_suiv )
suivant = Button ( text = " Prochaine génération " , command = gen_suiv )
suivant . grid ( row = 6 , column = 1 )
precedent = tk . Button ( text = " génération précédente " , command = gen_prev )
precedent = Button ( text = " génération précédente " , command = gen_prev )
precedent . grid ( row = 7 , column = 1 )
gen_continue = tk . Button ( text = " Génération en continue " , command = gen_cont )
gen_continue = Button ( text = " Génération en continue " , command = gen_cont )
gen_continue . grid ( row = 8 , column = 1 )
stop = tk . Button ( text = " Stop " , command = stop )
stop = Button ( text = " Stop " , command = stop )
stop . grid ( row = 9 , column = 1 )
################Système sauvegarde##########
save = tk . Button ( text = " Sauvegarder " , command = save )
save = Button ( text = " Sauvegarder " , command = save )
save . grid ( row = 4 , column = 3 )
load = tk . Button ( text = " Charger " , command = load )
load = Button ( text = " Charger " , command = load )
load . grid ( row = 5 , column = 3 )
zone . bind_all ( ' <Button-3> ' , change )
fenetre . mainloop ( )