Jeu du Pierre Feuille Ciseaux en Tkinter / Python
Alphasz
-
Utilisateur anonyme -
Utilisateur anonyme -
Bonjour, je souhaite développer un jeu de Pierre Feuille Ciseaux pour un devoir d'ISN (matière informatique en seconde) en tkinter, mais j'ai des messages d'érreur et je n'y comprend rien...
J'éspere que vous pourrez m'aider ...
#JEU DU PIERRE FEUILLE CISEAUX #MODULES from tkinter import * import random #FONCTIONS def scoreplus(ordi,joueur): global oscore, jscore if ordi == joueur : pfcegalite=Tk() pfcegalite.title("Egalité") egalite=Label(pfcegalite,text="Il y'a egalité") egalite.grid(row=1, column=2, padx=10, pady=10) quitter3=Button(pfcegalite,text="Quitter",command=pfcegalite.destroy) quitter3.grid(row=2, column=2, padx=10, pady=10) if (jscore == 1 and oscore== 3) or (jscore==2 and oscore==1) or (jscore==3 and oscore == 2) : pfcgagne=Tk() pfcgagne.title("Vous avez gagné") victoire=Label(pfcgagne,text="Victoire !") victoire.grid(row=1, column=2, padx=10, pady=10) quitter2=Button(pfcgagne,text="Quitter",command=pfcgagne.destroy) quitter2.grid(row=2, column=2, padx=10, pady=10) def jeu(joueur): global oscore, jscore, scores, monc ordi = random.randint(0,2) if ordi==0: votrec.config(text='Pierre') elif ordi==1: votrec.config(text='Feuille') else: votrec.config(text='Ciseaux') scoreplus(ordi,joueur) jscore.configure(text=str(jscore)) oscore.configure(text=str(oscore)) def pierre(): pierre.config(bg="green", fg="red") feuille.config(bg="red", fg="green") ciseaux.config(bg="red", fg="green") score() def feuille(): feuille.config(bg="green", fg="red") pierre.config(bg="red", fg="green") ciseaux.config(bg="red", fg="green") score() def ciseaux(): ciseaux.config(bg="green", fg="red") pierre.config(bg="red", fg="green") feuille.config(bg="red", fg="green") score() def recommencer(): pierre.config(bg="white", fg="black") feuille.config(bg="white", fg="black") ciseaux.config(bg="white", fg="black") pierre1.config(bg="white", fg="black") feuille1.config(bg="white", fg="black") ciseaux1.config( bg="white", fg="black") def score(): global oscore, jscore, pierre1, feuille1, ciseaux1 ordi = random.randint(0,2) if ordi==0: pierre1.config(state=("disabled"), bg="green", fg="red") feuille1.config(state=("disabled"), bg="red", fg="green") ciseaux1.config(state=("disabled"), bg="red", fg="green") monc.config(text='Pierre') if ordi==1: pierre1.config(state=("disabled"), bg="red", fg="green") feuille1.config(state=("disabled"), bg="green", fg="white") ciseaux1.config(state=("disabled"), bg="red", fg="green") monc.config(text='Feuille') if ordi==2: pierre1.config(state=("disabled"), bg="red", fg="green") feuille1.config(state=("disabled"), bg="red", fg="green") ciseaux1.config(state=("disabled"), bg="green", fg="red") monc.config(text='Ciseaux') #VARIABLES oscore = 0 jscore = 0 #configURATION DE LA FENÊTRE pfc=Tk() ; pfc.title("Jeu du Pierre Feuille Ciseaux") #TEXTES votrec=Label(pfc, text="Votre Choix :", font=("verdana", 12)).grid(row=1, column=1, padx=10, pady=10) monc=Label(pfc, text="Choix Aléatoire :", font=("verdana", 12)).grid(row=1, column=3, padx=10, pady=10) scores=Label(pfc, text="Score : " + str(jscore) + " - " + str(oscore), font=("verdana", 16)).grid(row=1, column=2, padx=10, pady=10) votrec=Label(pfc, text="...", font=("verdana", 12)).grid(row=2, column=2, padx=10, pady=10) vs=Label(pfc, text="CONTRE", font=("verdana", 13)).grid(row=3, column=2, padx=10, pady=10) monc=Label(pfc, text="...", font=("verdana", 12)).grid(row=4, column=2, padx=10, pady=10) #BOUTONS pierre=Button(pfc, text="Pierre", width=25, height=5, font=("verdana", 12), command=pierre) pierre.grid(row=2, column=1, padx=10, pady=10) feuille=Button(pfc, text="Feuille", width=25, height=5, font=("verdana", 12), command=feuille) feuille.grid(row=3, column=1, padx=10, pady=10) ciseaux=Button(pfc, text="Ciseaux", width=25, height=5, font=("verdana", 12), command=ciseaux) ciseaux.grid(row=4, column=1, padx=10, pady=10) pierre1=Button(pfc, text="Pierre", width=25, height=5, font=("verdana", 12), state=("disabled")) pierre1.grid(row=2, column=3, padx=10, pady=10) feuille1=Button(pfc, text="Feuille", width=25, height=5, font=("verdana", 12), state=("disabled")) feuille1.grid(row=3, column=3, padx=10, pady=10) ciseaux1=Button(pfc, text="Ciseaux", width=25, height=5, font=("verdana", 12),state=("disabled")) ciseaux1.grid(row=4, column=3, padx=10, pady=10) quitter=Button(pfc, text="Quitter", width=15, height=2, font=("verdana", 12), command = pfc.destroy) quitter.grid(row=5, column=3, padx=10, pady=10) recommencer=Button(pfc, text="Recommencer", width=15, height=2, font=("verdana", 12), command = recommencer) recommencer.grid(row=5, column=1, padx=10, pady=10) #AUTRES pfc.mainloop()
J'éspere que vous pourrez m'aider ...
A voir également:
- Python pierre feuille ciseaux
- Télécharger outil capture d'écran ciseaux - Télécharger - Capture d'écran
- Citizen code python avis - Accueil - Outils
- Feuille de score belote excel - Forum Excel
- Pierre eclat pokemon platine ✓ - Forum Jeux vidéo
- Symbole ciseaux word - Forum Word
2 réponses
L'erreur est :
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Alpahsz\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py", line 1549, in __call__
return self.func(*args)
File "x-wingide-python-shell://80491824/2", line 52, in feuille
File "x-wingide-python-shell://80491824/2", line 85, in score
AttributeError: 'NoneType' object has no attribute 'config'
Exception in Tkinter callback
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Alpahsz\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py", line 1549, in __call__
return self.func(*args)
File "x-wingide-python-shell://80491824/2", line 52, in feuille
File "x-wingide-python-shell://80491824/2", line 85, in score
AttributeError: 'NoneType' object has no attribute 'config'
Exception in Tkinter callback