from tkinter import * import random prix=0 def sandwich(): global prix fenetre=Tk() champ_label=Label(fenetre, text="CHOIX SANDWICH") champ_label.pack() if var_choix.get()=="MaxiBest of": prix=10 choix_sandwich1 = Radiobutton(fenetre, text="Big Mac", variable=var_choix, value="Big", bg="blue", bd= 20, width=20) choix_sandwich2 = Radiobutton(fenetre, text="Nuggets x9", variable=var_choix, value="Nugg9", bg="red", bd= 20, width=20) choix_sandwich3 = Radiobutton(fenetre, text="Royal Cheese", variable=var_choix, value="Cheese", bg="green", bd= 20, width=20) choix_sandwich1.pack() choix_sandwich2.pack() choix_sandwich3.pack() bouton_confirme2 = Button(fenetre, text="Je veux ce sandwich!", command=accompagnement, bg='coral', bd=20) bouton_confirme2.pack() if var_choix.get()=="Best of": prix=7 choix_sandwich1 = Radiobutton(fenetre, text="Cheeseburger", variable=var_choix, value="Cheese", bg="blue", bd= 20, width=20) choix_sandwich2 = Radiobutton(fenetre, text="Nuggets x6", variable=var_choix, value="Nugg6", bg="red", bd= 20, width=20) choix_sandwich3 = Radiobutton(fenetre, text="Hamburger", variable=var_choix, value="Ham", bg="green", bd= 20, width=20) choix_sandwich1.pack() choix_sandwich2.pack() choix_sandwich3.pack() bouton_confirme3 = Button(fenetre, text="Je veux ce sandwich!", command=accompagnement, bg='coral', bd=20) bouton_confirme3.pack() if var_choix.get()=="Happy Meal": prix=4 choix_sandwich1 = Radiobutton(fenetre, text="Hamburger", variable=var_choix, value="Ham", bg="blue", bd= 20, width=20) choix_sandwich2 = Radiobutton(fenetre, text="Nuggets x4", variable=var_choix, value="Nugg4", bg="red", bd= 20, width=20) choix_sandwich3 = Radiobutton(fenetre, text="Croque MacDo", variable=var_choix, value="Croque", bg="green", bd= 20, width=20) choix_sandwich1.pack() choix_sandwich2.pack() choix_sandwich3.pack() bouton_confirme4 = Button(fenetre, text="Je veux ce sandwich!", command=accompagnement, bg='coral', bd=20) bouton_confirme4.pack() def accompagnement(): fenetre=Tk() champ_label=Label(fenetre, text="CHOIX ACCOMPAGNEMENT") champ_label.pack() choix_accomp1 = Radiobutton(fenetre, text="Petite Frite", variable=var_choix, value="Petite Frite", bg="blue", bd= 20, width=20) choix_accomp2 = Radiobutton(fenetre, text="Grande Frite", variable=var_choix, value="Grande Frite", bg="red", bd= 20, width=20) choix_accomp1.pack() choix_accomp2.pack() bouton_quitter = Button(fenetre, text="Je veux cette frite!", command=boisson, bg='khaki', bd=20) bouton_quitter.pack() def boisson(): fenetre=Tk() champ_label=Label(fenetre, text="CHOIX ACCOMPAGNEMENT") champ_label.pack() choix_boisson1 = Radiobutton(fenetre, text="Coca Cola", variable=var_choix, value="Coca Cola", bg="red", bd= 20, width=20) choix_boisson2 = Radiobutton(fenetre, text="Jus d'orange", variable=var_choix, value="Jus d'orange", bg="orange", bd= 20, width=20) choix_boisson3 = Radiobutton(fenetre, text="Eau", variable=var_choix, value="Eau", bg="deepskyblue", bd= 20, width=20) choix_boisson1.pack() choix_boisson2.pack() choix_boisson3.pack() bouton_quitter = Button(fenetre, text="Je veux cette boisson!", command=demandedessert, bg='khaki', bd=20) bouton_quitter.pack() def demandedessert(): fenetre=Tk() champ_label=Label(fenetre, text="DESIREZ-VOUS UN DESSERT ?") champ_label.pack() bouton_oui = Button(fenetre, text="Oui", bg="red", bd= 20, width=20, command=dessert) bouton_non = Button(fenetre, text="Non", bg="blue", bd= 20, width=20, command=paiement) bouton_oui.pack() bouton_non.pack() def dessert(): global prix fenetre=Tk() champ_label=Label(fenetre, text="CHOIX ACCOMPAGNEMENT") champ_label.pack() prix = prix+2 choix_dessert1 = Radiobutton(fenetre, text="Cookie", variable=var_choix, value="Cookie", bg="blue", bd= 20, width=20) choix_dessert2 = Radiobutton(fenetre, text="Glace", variable=var_choix, value="Glace", bg="red", bd= 20, width=20) choix_dessert1.pack() choix_dessert2.pack() bouton_quitter = Button(fenetre, text="Je veux ce dessert!", command=paiement, bg='khaki', bd=20) bouton_quitter.pack() def paiement(): global ligne_texte fenetre=Tk() champ_label=Label(fenetre, text="COUT TOTAL : "+ str(prix) + "euros \n Veuillez insérer votre numéro de carte") #, print(prix) champ_label.pack() var_texte = StringVar() ligne_texte = Entry(fenetre, textvariable=var_texte, width=30) ligne_texte.pack() bouton_quitter = Button(fenetre, text="Valider", command=final, bg='khaki', bd=20) bouton_quitter.pack() def final(): global ligne_texte r = random.randint(1,100) if 999