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
| from tkinter import*
import random
from tkinter.messagebox import*
Nb= random.randrange(1,100)
def Compteur():
global Compteur
Compteur.set(int(Compteur.get())+1)
def obtener():
valor = CajaNumero.get()
print(valor.get())
def CplusCmoins():
c=0
Choix=valor.get()
if Choix < Nb:
c+=1
a= ('c est plus')
#print(a )
messagebox.showinfo("Resultat: "," "+ a)
elif Choix> Nb:
c+=1
a= ('c est moins')
#print(a)
("Resultat: "," "+ a)
else:
c+=1
a = ('bravo')
#print(a)
messagebox.showinfo("Resultat: "," "+ a)
ventana = Tk()
Choix= IntVar()
ventana.title("jeu du plus ou moins")
ventana.geometry('400x400')
fondo=PhotoImage(file="cascade.gif")
lblFondo=Label(ventana, image=fondo).place(x=0,y=0)
# Création d'un widget Button (bouton Quitter)
BoutonQuitter = Button(ventana, text ='Sortir', command = ventana.destroy)
BoutonQuitter.pack(side = RIGHT, padx = 10, pady = 10)
# Création d'un widget Button (bouton Conitunerr)
BoutonContinuer = Button(ventana, text ='Continuer')
BoutonContinuer.pack(side = LEFT, padx = 10, pady = 10)
valor = IntVar()
a= IntVar()
etiqueta1=Label(ventana,text= "ecris un nombre", fg="red").place(x=10,y=40)
CajaNumero=Entry(ventana,textvariable = valor, width=10).place(x=10, y=60)
boton2=Button(ventana, text="valider ",command= CplusCmoins).place(x=10, y=80)
ventana.mainloop() |
Partager