from tkinter import * from random import * def facile() : #Def qui prend un mot "Facile" global motaleatoire fichier = open ('facile.txt','r') liste = fichier.readlines() i = randrange(0,len(liste)) print(liste[i]) fichier.close() motaleatoire = liste[i] motcache = "" for i in range (len(motaleatoire)-1) : motcache = motcache+'*' print(motcache) def moyen() : #Def qui prend un mot "Moyen" fichier = open ('normal.txt','r') liste = fichier.readlines() i = randrange(0,len(liste)) print(liste[i]) fichier.close() motaleatoire = liste[i] motcache = "" for i in range (len(motaleatoire)-1) : motcache = motcache+'*' print(motcache) def difficile() : #Def qui prend un mot "Difficile" fichier = open ('difficile.txt','r') liste = fichier.readlines() i = randrange(0,len(liste)) print(liste[i]) fichier.close() motaleatoire = liste[i] motcache = "" for i in range (len(motaleatoire)-1) : motcache = motcache+'*' print(motcache) fen=Tk() fen.title("Interface") fen.geometry("800x500") b1=Button(fen,text="Mot Facile",command=facile) #Bouton à séléctionner pour choisir "Facile" b1.place(x=20,y=90) b2=Button(fen,text="Mot Moyen",command=moyen) #Bouton à sélectionner pour choisir "Moyen" b2.place(x=120, y=90) b3=Button(fen,text="Mot Difficile",command=difficile) #Bouton à sélectionner pour choisir "Difficile" b3.place(x=220, y=90) def affiche(x): print(x) print(motaleatoire) for i in range (len(motaleatoire)): if x == motaleatoire[i] : motaleatoire.pop(i) print(motaleatoire) can=Canvas(fen) for i in range (65,91): n=chr(i) b=Button(fen,text=n,command=lambda x=n:affiche(x)) if i <78: b.grid(column=i,row=0) else: b.grid(column=(i-13),row=1) fen.mainloop()