Bonjour
J'ai un programme qui est un test de personnalité et j’appelle la fonction qui régit le déroulement de ce test grâce à un bouton dans un menu.
Or, quand je l’appelle avec un bouton cela ne marche pas alors que quand je fais un appel simple (du type fonction()) cela marche et je ne comprends pas pourquoi.

merci d'avance
voici mon code

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
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
96
97
98
99
100
101
102
103
def valid ():
    squalala()
    answer()
 
def squalala ():
    global testi,testq, testp1, testp2, testp3, testp4, testp5
    testp1=0
    testp2=0
    testp3=0
    testp4=0
    testp5=0
    testi=testi+1
    testq.config(text=testquestions[testi])
    print (testréponse)
    testfinal=""
    if testi>9 :
        for testf in range (len(testréponse)):
            if testréponse[testf]=="z":
                testp1=testp1+1
            if testréponse[testf]=="y":
                testp2=testp2+1
            if testréponse[testf]=="k":
                testp3=testp3+1
            if testréponse[testf]=="g":
                testp4=testp4+1
            if testréponse[testf]=="p":
                testp5=testp5+1
        if testp5>testp4 and testp5>testp3 and testp5>testp2 and testp5>testp1 :
            testfinal="très social et à l'aise"
        if testp4>testp5 and testp4>testp3 and testp4>testp2 and testp4>testp1 :
            testfinal="social et à l'aise"
        if testp3>testp4 and testp3>testp5 and testp3>testp2 and testp3>testp1 :
            testfinal="dans la moyenne"
        if testp2>testp4 and testp2>testp3 and testp2>testp5 and testp2>testp1 :
            testfinal="social mais vous préférez les autres"
        if testp1>testp4 and testp1>testp3 and testp1>testp2 and testp1>testp5 :
            testfinal="un misanthrope taciturne"
 
        testfenfin=Tk()
        testfenfin.title("C'est fini")
        testfenfin.geometry("300x300")
        testfin=Label(testfenfin, text="Vous êtes {0}".format(testfinal))
        testfin.place(x=75,y=110)
        print(testp1, testp2, testp3, testp4, testp5)
 
def answer ():
    global testréponse, testrep1
    testrep2=testrep1.get()
    if testrep2==1 :
        testréponse.append("z")
    if testrep2==2 :
        testréponse.append("y")
    if testrep2==3 :
        testréponse.append("k")       #FAIS UNE LISTE ET UNE FONCTION UNIQUE
    if testrep2==4 :
        testréponse.append("g")
    if testrep2==5 :
        testréponse.append("p")
    print (testrep1.get())
 
def question():
    global testf, testf2, testi,testq, testrep1
    testrep1=IntVar()
    testr1=Radiobutton(testf,variable=testrep1,value=1,indicatoron=1,width=15)
    testr1.grid(row=3, column=1)
    testr2=Radiobutton(testf,variable=testrep1,value=2,indicatoron=1,width=15)
    testr2.grid(row=3, column=2)
    testr3=Radiobutton(testf,variable=testrep1,value=3,indicatoron=1,width=15)
    testr3.grid(row=3, column=3)
    testr3.invoke()
    testr4=Radiobutton(testf,variable=testrep1,value=4,indicatoron=1,width=15)
    testr4.grid(row=3, column=4)
    testr5=Radiobutton(testf,variable=testrep1,value=5,indicatoron=1,width=15)
    testr5.grid(row=3, column=5)
    testl1=Label(testf, text="Pas du tout")
    testl1.grid(row=3, column=0)
    testl1=Label(testf, text="Beaucoup")
    testl1.grid(row=3, column=7)
 
    testR=Button(testfen, text="Valider", command=valid).place(x=375, y=150)
 
def test_de_personnalité():
    global testfen, testquestions, testréponse, testf2, testf3, testi,testf, testq, testb, testquitter
    testfen=Tk()
    testfen.geometry("820x200")
    testfen.title("Test de personnalité")
    testquestions=["Prêt ?", "Es-tu social ?","Te sens tu bien avec les autres ?","Apprécies-tu les animaux ?","Préfères-tu les autres à la solitude ?","Tu ne te sens pas à l'aise avec le vouvoiement","1","2","3","4","Fini !"]
    testréponse=[]
 
    testf2=Frame(testfen)
    testf2.pack()
    testf3=Frame(testfen)
    testf3.pack()
    testi=0
    testf=Frame(testfen)
    testf.pack()
    testq=Label(testf,text=testquestions[testi])
    testq.grid(row=1, column=3)
    testb=Button(testf3, text='Commencer', command=question).pack()
    testquitter=Button(testf3, text="Quitter", command=testfen.destroy).pack()
 
 
    testfen.mainloop()
et le bouton qui appelle test_de_personnalité

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
fenmenu = Tk()
phquiz = PhotoImage(file="Images/point.png")
phpers = PhotoImage(file="Images/perso1.png")
phlaby = PhotoImage(file="Images/labymenu1.png")
fenmenu.title("Menu principal")
fenmenu.geometry("400x400")
Cquiz = Button(fenmenu, image=phquiz, command=quiz)
Cquiz.place(x=10,y=10)
Cpers = Button(fenmenu, image=phpers, command=test_de_personnalité)
Cpers.place(x= 260, y=10)
Claby = Button(fenmenu, image=phlaby, command=labyrinthe)
Claby.place(x=150, y=150)
boutonquitter=Button(fenmenu, text="Quitter", command=fenmenu.destroy)
boutonquitter.place(x=300, y=350)
fenmenu.mainloop()