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
|
fenetre=Tk.Tk()
fenetre.title('Choix du matériau')
var_choix=Tk.DoubleVar()
var_choix.set (7.8)
def memo():
memo = 0.0 + var_choix.get()
return memo
print ("memo", memo)
choix_acier = Tk.Radiobutton(fenetre, text="Acier", variable=var_choix,
value='7.8', command = memo)
choix_alu = Tk.Radiobutton(fenetre, text="Aluminium", variable=var_choix,
value='2.7', command = memo)
choix_bronze = Tk.Radiobutton(fenetre, text="Bronze", variable=var_choix,
value='8.8', command = memo)
choix_cuivre = Tk.Radiobutton(fenetre, text="Cuivre", variable=var_choix,
value='8.92', command = memo)
choix_titane = Tk.Radiobutton(fenetre, text="Titane", variable=var_choix,
value='4.5', command = memo)
choix_zinc = Tk.Radiobutton(fenetre, text="Zinc", variable=var_choix,
value='7.15', command = memo)
def result():
print (memo)
bouton_valid = Tk.Button (fenetre, text="Validez", command = result)
choix_acier.pack(side = Tk.LEFT, padx = 5, pady = 5)
choix_alu.pack(side = Tk.LEFT, padx = 5, pady = 5)
choix_bronze.pack(side = Tk.LEFT, padx = 5, pady = 5)
choix_cuivre.pack(side = Tk.LEFT, padx = 5, pady = 5)
choix_titane.pack(side = Tk.LEFT, padx = 5, pady = 5)
choix_zinc.pack(side = Tk.LEFT, padx = 5, pady = 5)
bouton_valid.pack(side = Tk.LEFT, padx = 5, pady = 5)
fenetre.mainloop() |
Partager