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
| from fcntl import DN_DELETE
from this import d
import tkinter as tk
import random
liste_ordi = [1,2,3,4,5,6,7,8,9]
L=[]
for i in range (4):
L.append(random.choice(liste_ordi))
liste_joueur = []
VBP=0
VMP=0
def effacer():
canvas1.delete(0, tk.END)
root= tk.Tk()
canvas1 = tk.Canvas(root, width = 400, height = 300)
canvas1.pack()
button3 = tk.Button(text='Recommencer', command=effacer)
button3.pack()
def tricher ():
label1 = tk.Label(root, text=L )
canvas1.create_window(100, 60, window=label1)
while VBP!=4:
button2 = tk.Button(text='Tricher', command=tricher)
canvas1.create_window(100, 80, window=button2)
entry1 = tk.Entry (root)
entry2 = tk.Entry (root)
entry3 = tk.Entry (root)
entry4 = tk.Entry (root)
canvas1.create_window(200, 100, window=entry1)
canvas1.create_window(200, 120, window=entry2)
canvas1.create_window(200, 140, window=entry3)
canvas1.create_window(200, 160, window=entry4)
liste_joueur = []
VBP=0
VMP=0
def getSquareRoot ():
x1 = entry1.get()
x2 = entry2.get()
x3 = entry3.get()
x4 = entry4.get()
liste_joueur.append(int(x1))
liste_joueur.append(int(x2))
liste_joueur.append(int(x3))
liste_joueur.append(int(x4))
label1 = tk.Label(root, text=liste_joueur )
label6 = tk.Label(root, text=L )
label2 = tk.Label(root, text='Felicitation' )
if L == liste_joueur:
label2 = tk.Label(root, text='Felicitation' )
canvas1.create_window(200, 250, window=label2)
else:
for i in range(len(liste_joueur)):
global VBP,VMP
if liste_joueur[i]==L[i]:
label3 = tk.Label(root, text="La valeur :"+ str(liste_joueur[i])+ " est bien place")
canvas1.create_window(200, 220, window=label3)
VBP=VBP +1
else:
VMP=VMP+ 1
label4 = tk.Label(root, text= "Nombre de valeurs bien places:"+str(VBP))
label5 = tk.Label(root, text="Nombre de valeurs mal places:"+str(VMP) )
canvas1.create_window(200, 290, window=label1)
canvas1.create_window(200, 250, window=label4)
canvas1.create_window(200, 270, window=label5)
button1 = tk.Button(text='Valider', command=getSquareRoot)
canvas1.create_window(200, 180, window=button1)
button2 = tk.Button(text='Continuer', command=getSquareRoot)
canvas1.create_window(200, 180, window=button1)
root.mainloop() |
Partager