Voilà, c'est la 1ère fois que je poste ici. J'ai fait quelques recherches sur le site pour trouver réponse à mon problème mais sans succès.

Donc je suis une grande novice en programmation, à vrai dire c'est pour mon projet du bac en informatique (soyez indulgent^^). Le but est de faire une borne de restauration où l'on peut prendre sa commande et ainsi de se faire livrer (ici afficher) le menu sélectionné via turtle (on a dessiner nos sandwichs, boissons, etc), que l'on appelle avec coca.fcoca, etc.

J'utilise donc python3.3.4 et voilà mon problème :

Lorsque que je donne une valeur aux différents menus pour qu'il me propose différents choix ça marche très, pour l'exemple, var_choix prend donc la valeur "MaxiBest of" et si je choisis le Big Mac, var_choix2 devrait prendre la valeur "Big" logiquement.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
from tkinter import *
import random
from turtle import *
import bacon, coca, royalcheese
 
prix=0
 
def sandwich():
        global var_choix2
        global prix
        fenetre2=Tk()
        champ_label=Label(fenetre2, text="CHOIX SANDWICH")
        champ_label.pack()
 
        var_choix2 = StringVar()
 
        if var_choix.get()=="MaxiBest of":
 
                prix=10
 
 
                choix_sandwich1 = Radiobutton(fenetre2, text="Big Mac", variable=var_choix2, value="Big", bg="blue", bd= 20, width=20)
                choix_sandwich2 = Radiobutton(fenetre2, text="Nuggets x9", variable=var_choix2, value="Nugg9", bg="red", bd= 20, width=20)
                choix_sandwich3 = Radiobutton(fenetre2, text="Royal Cheese", variable=var_choix2, value="Cheese", bg="green", bd= 20, width=20)
 
                choix_sandwich1.pack()
                choix_sandwich2.pack()
                choix_sandwich3.pack()
 
 
                bouton_confirme2 = Button(fenetre2, text="Je veux ce sandwich!", command=accompagnement, bg='coral', bd=20)
                bouton_confirme2.pack()
 
#j'ai enlevé ici une partie du script inutile 
 
def valide():
	bouton_confirme.pack()
 
fenetre=Tk()
champ_label=Label(fenetre, text="CHOIX MENU")
champ_label.pack()
 
 
 
var_choix = StringVar()
 
choix_menu1 = Radiobutton(fenetre, text="Menu Maxi Best of", variable=var_choix, value="MaxiBest of", bg="deepskyblue", bd= 20, width=20, command=valide)
choix_menu2 = Radiobutton(fenetre, text="Menu Best of", variable=var_choix, value="Best of", bg="red", bd= 20, width=20, command=valide)
choix_menu3 = Radiobutton(fenetre, text="Menu Happy Meal", variable=var_choix, value="Happy Meal", bg="green", bd= 20, width=20, command=valide)
 
choix_menu1.pack()
choix_menu2.pack()
choix_menu3.pack()
 
bouton_confirme = Button(fenetre, text="Confirmer", command=sandwich,  bg="khaki", bd=10)
 
 
fenetre.mainloop()
Et pourtant à la fin il s'affiche seulement ma fenêtre sans mes boutons alors que var_choix2 devrait avoir la valeur "Big".

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def miam():
        global var_choix2
        fenetre=Tk()
        if var_choix2.get()=="Big":
                bouton_sand = Button(fenetre, text="Votre sandwich", command=bacon.fbacon)
                bouton_boi = Button(fenetre, text="Votre boisson", command=coca.fcoca)
 
                bouton_sand.pack()
                bouton_boi.pack()
 
        if var_choix2.get()=="Cheese":
                bouton_sand= Button(fenetre, text="Votre sandwich", command=bacon.froyal)
                bouton_boi = Button(fenetre, text="Votre boisson", command=coca.fcoca)
 
                bouton_sand.pack()
                bouton_boi.pack()
Voilà je tourne en rond depuis un moment, une petite aide serait la bienvenue
Je vous met les fichiers complet si besoin: coca.py bacon.py royalcheese.py projet.py