Tkinter boucle label image

Tags: #<Tag:0x00007f63f26f9ae8>

bonjour
je cherche a afficher 10 images avec tkinter grace a une boucle or seul la derniere est afficher. J’utilise pourtant la meme methode que pour afficher 10 textes qui s’affiche très bien.

for i in range(10):
    tempah = Label(buttom_frame,text=str(data['hourly']['temperature_2m'][heure_act + i +24 * jourselect]) +"°C \n" + str(heure_act + i) + "H",bg=couleuract)
    tempah.place(rely=0.8,relx=0.1*i, relwidth=0.1, relheight=0.2)


    ptitimg0 = PhotoImage(file=str(dic_couleur_fond[sky(jourselect,int(heure_act+i))][2] ), width=125, height=125)
    f0 = Label(buttom_frame, image=ptitimg0,bg =couleuract)
    f0.update()
    f0.place(rely=0.2,relx=0.1*i,relwidth=0.1, relheight=0.6 )

Essaie de créer tempah et f0 avant la boucle.
Ou alors tu crées 20 Label distincts dans une liste.

Comme ça ?

def temp0a24(colo):
global date_heure_affiche, jourselect, heure_act
global couleuract, ptitimg0,ptitimg1,ptitimg2,ptitimg3,ptitimg4,ptitimg5,ptitimg6,ptitimg7,ptitimg8,ptitimg9

ptitimg0 = PhotoImage(file=str(dic_couleur_fond[sky(jourselect,int(heure_act+0))][2] ), width=125, height=125)
f0 = Label(buttom_frame, image=ptitimg0,bg =couleuract)
for i in range(10):
    tempah = Label(buttom_frame,text=str(data['hourly']['temperature_2m'][heure_act + i +24 * jourselect]) +"°C \n" + str(heure_act + i) + "H",bg=couleuract)
    tempah.place(rely=0.8,relx=0.1*i, relwidth=0.1, relheight=0.2)
    ptitimg0.configure(file=str(dic_couleur_fond[sky(jourselect,int(heure_act+i))][2]) )

    f0.place(rely=0.2,relx=0.1*i,relwidth=0.1, relheight=0.6 )

Non :

temp=[]
f=[]
for i in range(10):
  temp.append(Label(machin,truc))
  temp[-1].place(bidule)
  […]
  f0.append(Label(truc, machin))
  f0[-1].place(bidule)

image
toujours que la dernière image qui s’affiche