# Tkinter boucle label image

**URL:** <https://www.debian-fr.org/t/tkinter-boucle-label-image/87672>\
**Category:** Programmation\
**Tags:** python\
**Created:** [Janvier 4, 2023, 6:31 UTC](https://www.debian-fr.org/t/tkinter-boucle-label-image/87672 "2023-01-04T18:31:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LUX-recco](https://www.debian-fr.org/user_avatar/www.debian-fr.org/lux-recco/32/9428_2.png) [@LUX-recco](https://www.debian-fr.org/u/LUX-recco)\
**Post date:** [Janvier 4, 2023, 6:31 UTC](https://www.debian-fr.org/t/tkinter-boucle-label-image/87672/1 "2023-01-04T18:31:12Z")

</div>

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 )
```

---

<div class="post-metadata">

**Author:** ![nicola](https://www.debian-fr.org/user_avatar/www.debian-fr.org/nicola/32/8969_2.png) [@nicola](https://www.debian-fr.org/u/nicola)\
**Post date:** [Janvier 4, 2023, 6:54 UTC](https://www.debian-fr.org/t/tkinter-boucle-label-image/87672/2 "2023-01-04T18:54:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![LUX-recco](https://www.debian-fr.org/user_avatar/www.debian-fr.org/lux-recco/32/9428_2.png) [@LUX-recco](https://www.debian-fr.org/u/LUX-recco)\
**Post date:** [Janvier 4, 2023, 7:02 UTC](https://www.debian-fr.org/t/tkinter-boucle-label-image/87672/3 "2023-01-04T19:02:16Z")

</div>

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 )
```

---

<div class="post-metadata">

**Author:** ![nicola](https://www.debian-fr.org/user_avatar/www.debian-fr.org/nicola/32/8969_2.png) [@nicola](https://www.debian-fr.org/u/nicola)\
**Post date:** [Janvier 4, 2023, 7:06 UTC](https://www.debian-fr.org/t/tkinter-boucle-label-image/87672/4 "2023-01-04T19:06:23Z")

</div>

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)
```

---

<div class="post-metadata">

**Author:** ![LUX-recco](https://www.debian-fr.org/user_avatar/www.debian-fr.org/lux-recco/32/9428_2.png) [@LUX-recco](https://www.debian-fr.org/u/LUX-recco)\
**Post date:** [Janvier 4, 2023, 7:17 UTC](https://www.debian-fr.org/t/tkinter-boucle-label-image/87672/7 "2023-01-04T19:17:07Z")

</div>

![image](https://www.debian-fr.org/uploads/default/original/2X/8/8baaf41b758b1bc2c861c22e395a1dc2d48f80df.png)  
toujours que la dernière image qui s’affiche
