Bonjour, j'aimerai savoir si il est possible de rentrer plusieurs fonctions dans une même fonction. En effet dans mon programme j'ai besoin d'intégrer plusieurs fonctions dans une même fonctions, mais lorsque ma fenêtre s'ouvre (je programme sur tkinter une interface graphique) mes fonctions sont comme "gelés", aucune ne se met en route. Je ne sais pas si j'ai fais une erreur dans la programmation (n'ayant aucun message d'erreur) ou si tout simplement c'est impossible. Je sais qu'il existe d'autres méthodes comme les classes, mais nous ne les avons jamais étudié en cours... Merci de votre aide. 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
#Création de la fenêtre d'introduction
fenetreintro = tk.Tk()
label = tk.Label(fenetreintro, text="Wanted")
label.pack()
canvas=tk.Canvas(fenetreintro, width=800, height=500, background='white')
canvas.pack()
 
#Chemin pour les images
script_dir = os.path.dirname(__file__)
rel_path = "/images/"
abs_file_path = script_dir + rel_path
 
photo = Image.open(abs_file_path+"wanted.jpeg")
photowanted = ImageTk.PhotoImage(photo)
wanted=canvas.create_image(400, 200, image=photowanted)
 
#Fenêtre jeu
def FenetreJeu():
    fenetrejeu = tk.Tk()  
    titre1 = tk.Label(fenetrejeu, text="Wanted-Jeu")  
    titre1.pack() 
    Minuteur=tk.Label(fenetrejeu,text="60") 
    Minuteur.pack()  
    canvasjeu=tk.Canvas(fenetrejeu, width=800, height=800, background='white')  
    canvasjeu.pack()  
 
    image = Image.open(abs_file_path+"clarys2.png")  
    photoclarys2 = ImageTk.PhotoImage(image)
    canvasjeu.create_image(500,150, image=photoclarys2) 
 
    actu=60 
 
    def chrono():  
        global actu  
        if actu>-1: 
            Minuteur.config(text=str(actu))  
            actu=actu-1  
            fenetrejeu.after(1000,chrono) 
        else: 
            Minuteur.config(text="PERDU")
    chrono()      
 
    dx = tk.IntVar()  
    dy = tk.IntVar()  
 
    images0 = [0]*12
    images = [0]*12
    noms = ["clarys", "baptiste", "anais", "allan", "arnold", "thomas", "ayoub", "caroline", "deborah", "louis", "paul", "nono"]
 
    for i in range(12):
        images0[i] = ImageTk.PhotoImage(Image.open(abs_file_path + noms[i] + ".png"))
        images[i]=canvasjeu.create_image(50+50*i,300,image=images0[i])
 
    def deplacement ():
        dx.set(0)
        dy.set(5)
        for i in range(12):
            if canvasjeu.coords(images[i])[1]>400 :
                canvasjeu.coords(images[i],50+50*i,300)
                canvasjeu.move(images[i],dx.get(),dy.get())
            fenetrejeu.after(60,deplacement)  
 
    deplacement() 
 
    fenetrejeu.mainloop() 
 
#Fenêtre instructions
def FenetreInstructions(): 
    fenetreinstructions=tk.Tk()
    titre2=tk.Label(fenetreinstructions, text="INSTRUCTIONS AU JEU")
    titre2.pack()
 
bouton1=tk.Button(fenetreintro, text="PLAY", command=FenetreJeu)
bouton1.pack()
 
bouton2=tk.Button(fenetreintro, text="Instructions", command=FenetreInstructions)
bouton2.pack()
 
bouton3=tk.Button(fenetreintro, text="Quitter", command=fenetreintro.destroy)
bouton3.pack()
 
fenetreintro.mainloop()