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
|
from tkinter import *
import random
def evaluer(event):
chaine.configure(text='Résultat = '+str(eval(entree.get())))
fenetre = Tk()
fenetre['bg']='white'
def fonctionboutonradio():
global variable1
global variable2
x=mode.get() #je pense que l'utilisation des boutons radio ne se fait pas de cette maniere
y=niveau.get()
if x==1 and y==6: #en effet, si cela marchais ainsi et que je selectionnais le mode addition et le niveau 1 je passerai par la forcement
variable1=random.randint(1,9) #ainsi variable1 et 2 prendrais de nouvelles valeur diferent de 0
variable2=random.randint(1,9)
enonce= Label(fenetre, background='white',text=str(variable1)) #et la il s'afficherait forcement quelque chose...
enonce.pack(side=LEFT, padx=30, pady=30) #et en lancant le programme vous verrez que rien ne s'affiche
enonce= Label(fenetre, background='white',text="+") #conclusion: x est different de 1 et y de 6 car on ne passe pas dans cette boucle
enonce.pack(side=LEFT, padx=31, pady=30) #ducoup pourriez vous reregarder dans vos programme comment on utilise les radio bouton????
enonce= Label(fenetre, background='white',text=str(variable2))
enonce.pack(side=LEFT, padx=32, pady=30)
if x==1 and y==7:
variable1=random.randint(10,20)
variable2=random.randint(10,20)
if x==1 and y==8:
variable1=random.randint(21,30)
variable2=random.randint(21,30)
if x==1 and y==9:
variable1=random.randint(31,40)
variable2=random.randint(31,40)
if x==1 and y==10:
variable1=random.randint(41,50)
variable2=random.randint(41,50)
mode = StringVar()
bouton1 = Radiobutton(fenetre, text="Addition", variable=mode, value=1)
bouton2 = Radiobutton(fenetre, text="Soustraction", variable=mode, value=2)
bouton3 = Radiobutton(fenetre, text="Multiplication", variable=mode, value=3)
bouton4 = Radiobutton(fenetre, text="Division", variable=mode, value=4)
bouton1.pack(side=LEFT, padx=0, pady=2)
bouton2.pack(side=LEFT, padx=2, pady=2)
bouton3.pack(side=LEFT, padx=4, pady=2)
bouton4.pack(side=LEFT, padx=6, pady=2)
niveau = StringVar()
bouton11 = Radiobutton(fenetre, text="niveau 1", variable=niveau, value=6)
bouton22 = Radiobutton(fenetre, text="niveau 2", variable=niveau, value=7)
bouton33 = Radiobutton(fenetre, text="niveau 3", variable=niveau, value=8)
bouton44 = Radiobutton(fenetre, text="niveau 4", variable=niveau, value=9)
bouton55 = Radiobutton(fenetre, text="niveau 5", variable=niveau, value=10)
bouton11.pack()
bouton22.pack()
bouton33.pack()
bouton44.pack()
bouton55.pack()
Frame1 = Frame(fenetre, borderwidth=2, relief=GROOVE)
Frame1.pack(side=LEFT, padx=30, pady=30)
Label(Frame1, text="Bonjour, ce pogrammme est un jeu éducatif, qui reprend le principe de little professor, choississez un mode et un niveau",bg="red").pack(padx=10, pady=10)
Boutonradiovaleur = Button(fenetre, text ='definir les nombres aléeatoires', command=fonctionboutonradio )
Boutonradiovaleur.pack()
entree = Entry(fenetre, background='white')
entree.bind("<Return>", evaluer)
chaine = Label(fenetre)
entree.pack()
chaine.pack() |
Partager