bonjour à tous,
je tente depuis un bon moment d'utiliser les canevas de tkinter et je rencontre un petit probleme.
en gros je souhaite poser plusieurs images dans un popup tkinter.

dans un premier temps j'ai tenté de faire plusieurs canevas indépendant et j'ai fait avec le bout code suivant:

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
can1 = Canvas(fen1, width =80, height =80, bg ='red')
photo = PhotoImage(file ='image\img jackpot\poire.gif')
item = can1.create_image(40, 40, image =photo)
 
can2 = Canvas(fen1, width =80, height =80, bg ='red')
photo = PhotoImage(file ='image\img jackpot\poire.gif')
item = can2.create_image(40, 40, image =photo)
 
can3 = Canvas(fen1, width =80, height =80, bg ='red')
photo = PhotoImage(file ='image\img jackpot\poire.gif')
item = can3.create_image(40, 40, image =photo)
 
can1.grid(row =4, column =1, columnspan =1)
can2.grid(row =4, column =2, columnspan =1)
can3.grid(row =4, column =3, columnspan =1)
le code complet est le suivant:
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
 
 
def alea():
	import random
	r = random.randint(1,6)
	return r
 
def info(x):
        if x==1 :
                te="banane"
        if x==2 :
                te="pomme"
        if x==3 :
                te="poire"
        if x==4 :
                te="BAR"
        if x==5 :
                te="cerise"
        if x==6 :
                te="ananas"        
        return te
 
def gain(un,de,tr,gain,somme):
        if un==1 and de==1 and tr==1:
                mul=2
        elif un==1 and de==1:
                mul=1.1
        elif un==1 and tr==1:
                mul=1.1
        elif de==1 and tr==1:
                mul=1.1
 
        elif un==2 and de==2 and tr==2:
                mul=3
        elif un==2 and de==2:
                mul=1.2
        elif un==2 and tr==2:
                mul=1.2
        elif de==2 and tr==2:
                mul=1.2
 
        elif un==3 and de==3 and tr==3:
                mul=4
        elif un==3 and de==3:
                mul=1.3
        elif un==3 and tr==3:
                mul=1.3
        elif de==3 and tr==3:
                mul=1.3
 
        elif un==4 and de==4 and tr==4:
                mul=5
        elif un==4 and de==4:
                mul=1.4
        elif un==4 and tr==4:
                mul=1.4
        elif de==4 and tr==4:
                mul=1.4
 
        elif un==5 and de==5 and tr==5:
                mul=6
        elif un==5 and de==5:
                mul=1.5
        elif un==5 and tr==5:
                mul=1.5
        elif de==5 and tr==5:
                mul=1.5
 
        elif un==6 and de==6 and tr==6:
                mul=7
        elif un==6 and de==6:
                mul=1.6
        elif un==6 and tr==6:
                mul=1.6
        elif de==6 and tr==6:
                mul=1.6           
        else :
                mul=-1
 
        somme=int(somme+gain*mul)
 
        return somme        
 
def start_it():
 
        "démarrage de l'animation"
        global argent
        global reste
        pari =int(entr1.get())
 
        a=alea()
        b=alea()
        c=alea()
 
        d=info(int(a))
        e=info(int(b))
        f=info(int(c))
 
        txt4.configure(text = d)
        txt5.configure(text = e)
        txt6.configure(text = f)
 
        argent = gain(a,b,c,pari,argent)
 
        txt7.configure(text = 'il vous argent '+str(argent)+' euros')
 
 
 
import os
from tkinter import *
 
argent = 100
 
 
pari = 0
e=d=f="vide"
 
toto = 'il vous argent ',argent,' euros'
fen1 = Tk()
# création de widgets 'Label' et 'Entry' :
txt1 = Label(fen1, text ='bienvenue, vous avez')
txt2 = Label(fen1, text =argent)
txt3 = Label(fen1, text ='euro pour jouer')
txt4 = Label(fen1, text =e)
txt5 = Label(fen1, text =d)
txt6 = Label(fen1, text =f)
txt7 = Label(fen1, text =toto)
entr1 = Entry(fen1)
 
#poisitionnement photo
can1 = Canvas(fen1, width =80, height =80, bg ='red')
photo = PhotoImage(file ='image\img jackpot\poire.gif')
item = can1.create_image(40, 40, image =photo)
 
can2 = Canvas(fen1, width =80, height =80, bg ='red')
photo = PhotoImage(file ='image\img jackpot\poire.gif')
item = can2.create_image(40, 40, image =photo)
 
can3 = Canvas(fen1, width =80, height =80, bg ='red')
photo = PhotoImage(file ='image\img jackpot\poire.gif')
item = can3.create_image(40, 40, image =photo)
 
 
 
bou2 = Button(fen1, text='Démarrer', width =8, command=start_it)
bou2.pack()
 
 
txt1.grid(row =1, column =1)
txt2.grid(row =1, column =2)
txt3.grid(row =1, column =3)
 
txt4.grid(row =3, column =1)
txt5.grid(row =3, column =2)
txt6.grid(row =3, column =3)
 
can1.grid(row =4, column =1, columnspan =1)
can2.grid(row =4, column =2, columnspan =1)
can3.grid(row =4, column =3, columnspan =1)
 
txt7.grid(row =6, column =2)
 
entr1.grid(row =2, column =2)
 
bou2.grid(row =2, column =3)
fen1.mainloop()
bon deja j'ai coloré les canevas en rouge pour mieux les voire, ensuite j'ai utilisé la fonction grid car je la trouve plutot pratique pour organiser la fenetre.
et voila le resultat obtenue:
Nom : Sans titre.png
Affichages : 588
Taille : 22,0 Ko
je vois bien mes 3 canevas mais seulement un seul a la photo.

est ce que je suis passé à coté de quelque chose?
merci d'avance pour votre aide.