1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
| from tkinter import*
import sys
import tkinter as tk
import motusConsole
y = 37.5
canvas = None
entre = None
motComplete = []
motBase = None
positionLettresMalPlacees = []
bienPlacee = []
essaie = 0
quote = ""
mot=""
erreur = []
red = (255,255,255)
#-----------------Chrono-------------------------#
##def Bienvenue(label):
## root4.title("Bienvenue")
##frame = Frame(root4)
##frame.grid()
##button = Button(frame)
##button['text'] ="| Rentrer dans le JEU |"
##button['command'] = root4.destroy
##button.grid()
##root4 = Tk()
##label = tk.Label(root4, fg="khaki", bg = "green")
##label.grid(row=1,column=4)
##label.config(text=str(counter), font=("Arial Black", 20))
##label.config(text="Bienvenue sur le JEU MOTUS : Réalisé par Ilies - Enzo et Thomas")
##Bienvenue(label)
def afficherMotChosis(mot):
global y
global canvas
liste = motusConsole.mini_en_Maj(mot)
#print(liste)
x = 37.5
for loop in range(len(liste)): #Affichage
canvas.create_text( x,y,text=liste[loop],font=("Arial Black", 25), fill = 'white')
x=x+75
y = y + 75
def afficherMotComplete(mot,motChoisi):
global y
global canvas
global motComplete
liste = motusConsole.mini_en_Maj(mot)
#print(liste)
x = 37.5
for loop in range(len(liste)): #Mot bien placé et mal placé + MotComplete
if liste[loop] == motChoisi[loop]:
motComplete[loop] = motChoisi[loop]
bienPlacee.append(loop)
elif liste[loop] in motChoisi:
positionLettresMalPlacees.append(loop)
positionLettresMalPlacees
print(positionLettresMalPlacees) #A enlever apres
for loop in range(len(motComplete)): #Affichage
canvas.create_text( x,y,text=motComplete[loop],font=("Arial Black", 25),fill = 'white')
x=x+75
y = y + 75
def creationInterface(nbLettre,motChoisi):
global canvas
global entre
global motBase
#-------------------------------------------------------------------------------#
root = Tk()
root.title("MOTUS")
root.configure(background = 'coral1')
#-------------------------------------------------------------------------------#
#----------"MOTUS" AFFICHAGE----------------#
label_one = Label(root, text = '|MOTUS|',font=("Arial", 40), fg = "white",bg = "coral1" )
label_one.grid(row = 0)
#-------------------------------------------------------------------------------#
#----------Label Veuillez entrer un mot---------#
Label(root, text = "Veuillez entrer un mot", bg="cyan",fg="tomato",font="none 12 bold").grid(row=1,column=0)
#-------------------------------------------------------------------------------#
#----------------Boite d'entrée---------------#
entre = Entry(root)
entre.grid(row=2,column=0)
#-------------------------------------------------------------------------------#
#--------------Creation des lignes--------------#
y = 25
canvas_width = nbLettre * 75
canvas_height = 900
canvas = Canvas(root, width=canvas_width,height=canvas_height, bg="deep sky blue")
x0,y0,x1,y1= 0,0,nbLettre*75,0 #Lignes
for loop in range(12):
canvas.create_line(x0,y0,x1,y1,width = 2, fill="white")
y0= y0 + 75
y1= y1 + 75
x0,y0,x1,y1= 0,0,0,nbLettre*150 #Colones
for loop in range(nbLettre+1):
canvas.create_line(x0,y0,x1,y1,width = 2,fill="white")
#476042
x0= x0 + 75
x1= x1 + 75
canvas.grid(row =5)
#-------------------------------------------------------------------------------#
#----------------Bouton---------------#
bouton = Button(root, text="ENTREE", command=boutonClic)
bouton.grid(row=3,column=0)
#-------------------------------------------------------------------------------#
motComplete.append(motChoisi[0])
erreur.append(".")
for loop in range (len(motChoisi) - 1):
motComplete.append(" ")
erreur.append(".")
afficherMotChosis(motComplete)
#-------------------------------------------------------------------------------#
motBase = list(motChoisi)
#-------------------------------------------------------------------------------#
#Affichage résultat
## t = Text(root, height=2, width=30)
## quote = "vous avez gagné","Le mot etait : ",motBase
## t.insert(END, quote)
## t.grid(row=7,column=0)
root.mainloop()
return canvas
#------------------------------------------------#
def boutonClic():
global essaie
mot = entre.get()
if mot.isalpha() == True:
mot = str(mot)
mot = list(mot)
mot = motusConsole.mini_en_Maj(mot)
if motBase != mot and essaie < 6:
if len(mot) == len(motBase):
if motusConsole.validiteMot(mot) == False :
print("Ecrire un mot qui existe dans la langue francaise Merci.")
else:
afficherMotChosis(mot)
afficherMotComplete(mot,motBase)
essaie = essaie + 1
else:
mot = erreur
afficherMotChosis(mot)
afficherMotComplete(mot,motBase)
root3 = Tk()
root3.title("Erreur")
label = tk.Label(None, text="Ton mot n'est pas de bonne longueur, tu as perdu un essaie", font=('Times', '18'),fg='red')
label.grid()
print("Ton mot n'est pas de bonne longueur, tu as perdu un essaie")
essaie = essaie +1
elif motBase == mot and essaie < 6:
root3 = Tk()
root3.title("Erreur")
textwin = Label(root3, text = 'Vous avez gagné en ',bg = "red",fg="white", font = "Arial 10" ).grid(row = 1, column = 2)
print(textwin, end = '')
textnbessai = Label(root3, text = str(essaie+1), font = "Arial 10" ).grid(row = 1, column = 4)
print(textnbessai, end = '')
textessai = Label(root3, text = 'essai(s)', font = "Arial 10" ).grid(row = 1, column = 6)
print(textessai)
elif motBase != mot and essaie == 6:
textlose = text = Label(root3, text = 'Vous avez perdu.. ', font = "Arial 10" ).grid(row = 1, column = 4)
print(textlose)
else:
root2 = Tk()
frame = Frame(root2)
frame.grid()
button = Button(frame)
button['text'] ="| Ok |"
button['command'] = root2.destroy
button.grid()
root2.title("Erreur")
label = tk.Label(root2, text='Ne rentrez que des lettres Merci', font=('Times', '18'),fg='red')
label.grid()
#------------------------------------------------#
def main():
global canvas
motChoisi = motusConsole.choixDuMot()
canvas = creationInterface(len(motChoisi),motChoisi)
main() |
Partager