Forum EduPython

Echanges autour d'EduPython.

Vous n'êtes pas identifié(e).

#1 2019-06-02 11:10:20

Jonathan
Membre
Inscription : 2019-06-02
Messages : 1

Projet ISN

S'il vous plaît j'ai besoin d'aide on a presque fini le programme qui est un jeu de nim mais le problème c'est que l'on arrive pas à supprimer plusieurs allumettes enfin qu'il y ai plusieurs tours etc etc on arrive juste à supprimer les 3 premières et on n'arrive pas à trouver un moyen

from tkinter import*
from tkinter.filedialog import *

def regles():
    Top =Toplevel(maFenetre)
    Top.geometry("1200x500")
    Top.title("Règles")
    Top.resizable(height = False, width = False)
    Top.config(background='peach puff')

    label_title = Label(Top, text="Bienvenue sur le jeu de Nim", font= ("Lucida Calligraphy",30),background='peach puff', fg='tan4' )
    label_title.pack()
    label_title = Label(Top, text="Les règles sont simples: un certain nombre d'allumettes seront placées sur la table.", font= ("Lucida Calligraphy",20),background='peach puff', fg='tan4' )
    label_title.pack()
    label_title = Label(Top, text="Le programme et vous, enlèvera tour par tour, 1, 2 ou 3 allumettes", font= ("Lucida Calligraphy",20),background='peach puff', fg='tan4' )
    label_title.pack()
    label_title = Label(Top, text="celui qui enlève la dernière allumettes aura gagné. Bonne chance!", font= ("Lucida Calligraphy",20),background='peach puff', fg='tan4' )
    label_title.pack()

def enleveruneallumette():
    can1.destroy()

def enlever2allumettes():
    can1.destroy()
    can2.destroy()

def enlever3allumettes():
    can1.destroy()
    can2.destroy()
    can3.destroy()


#MENU PRINCIPAL
maFenetre = Tk()
maFenetre.geometry("900x800")
maFenetre.title("Jeu de nim")
maFenetre.resizable(height = False, width = False)
maFenetre.config(bg = 'peach puff')


#ajouter un titre
label_title = Label(maFenetre, text="Bienvenue sur le jeu de Nim", font = ("Lucida Calligraphy",30),background ='peach puff', fg='tan4' )
label_title.pack()

#pour afficher le boutton 1 allumette
Button1 = Button(maFenetre, text = "1 allumette", font = ("Lucida Calligraphy",30, ), fg="peachpuff4",overrelief=SUNKEN,command=enleveruneallumette, bg= 'antiquewhite' )
Button1.pack(side = BOTTOM, padx = 5, pady = 5)

#pour afficher le boutton 2 allumettes
Button2 = Button(maFenetre, text="2 allumettes", font=("Lucida Calligraphy",30), fg="peachpuff4",overrelief=SUNKEN, command=enlever2allumettes, bg = "antiquewhite")
Button2.pack(side=BOTTOM, padx = 5, pady = 5)

#pour afficher le boutton 3 allumettes
Button3 = Button(maFenetre, text="3 allumettes", font=("Lucida Calligraphy",30), fg="peachpuff4",overrelief=SUNKEN, command=enlever3allumettes, bg="antiquewhite")
Button3.pack(side=BOTTOM, padx = 5, pady = 5)

# regles
Bouton_aide = Button(maFenetre, text = '?' ,fg = 'black', command = regles, bg = 'peach puff', relief=FLAT)
Bouton_aide.place(anchor='nw')

#pour afficher les allumettes
can1 = Canvas(width=70, height=200, bg="peach puff", highlightbackground="peach puff")
img = PhotoImage(file='match.png')
can2 = Canvas(width=70, height=200, bg="peach puff", highlightbackground="peach puff")
img = PhotoImage(file='match.png')
can3 = Canvas(width=70, height=200, bg="peach puff", highlightbackground="peach puff")
img = PhotoImage(file='match.png')
can4 = Canvas(width=70, height=200, bg="peach puff", highlightbackground="peach puff")
img = PhotoImage(file='match.png')
can5 = Canvas(width=70, height=200, bg="peach puff", highlightbackground="peach puff")
img = PhotoImage(file='match.png')
can6 = Canvas(width=70, height=200, bg="peach puff", highlightbackground="peach puff")
img = PhotoImage(file='match.png')
can7 = Canvas(width=70, height=200, bg="peach puff", highlightbackground="peach puff")
img = PhotoImage(file='match.png')
can8 = Canvas(width=70, height=200, bg="peach puff", highlightbackground="peach puff")
img = PhotoImage(file='match.png')
can9 = Canvas(width=70, height=200, bg="peach puff", highlightbackground="peach puff")
img = PhotoImage(file='match.png')
can10 = Canvas(width=70, height=200, bg="peach puff", highlightbackground="peach puff")
img = PhotoImage(file='match.png')
can11 = Canvas(width=70, height=200, bg="peach puff", highlightbackground="peach puff")
img = PhotoImage(file='match.png')
can12 = Canvas(width=70, height=200, bg="peach puff", highlightbackground="peach puff")
img = PhotoImage(file='match.png')


can1.create_image(30,55, image=img) #1allumette
can1.pack(side=LEFT)
can2.create_image(30,55 , image=img) #2allumette
can2.pack(side=LEFT)
can3.create_image(30,55 , image=img) #3allumette
can3.pack(side=LEFT)
can4.create_image(30,55 , image=img) #4allumette
can4.pack(side=LEFT)
can5.create_image(30,55 , image=img) #5allumette
can5.pack(side=LEFT)
can6.create_image(30,55 , image=img) #6allumette
can6.pack(side=LEFT)
can7.create_image(30,55 , image=img) #7allumette
can7.pack(side=LEFT)
can8.create_image(30,55 , image=img) #8allumette
can8.pack(side=LEFT)
can9.create_image(30,55 , image=img) #9allumette
can9.pack(side=LEFT)
can10.create_image(30,55 , image=img) #10allumette
can10.pack(side=LEFT)
can11.create_image(30,55 , image=img) #11allumette
can11.pack(side=LEFT)
can12.create_image(30,55 , image=img) #12allumette
can12.pack(side=LEFT)


maFenetre.mainloop()


Merci d'avance. Cordialement.

Hors ligne

Pied de page des forums