0

This is the code and expected output for a revive box that i created for a practice project revboxppl frame contains three labels l1,l2,l3 and each label contains the same image ill.png

ill.png <--image

#FRAME FOR BORDER
revbox = Frame(root, bg="#C5B358", bd=10, relief="ridge")
revbox.place(relwidth=0.19, relheight=0.1, relx=0.74, rely=0.76)     

#FRAME OF PURPLE COLOUR
revboxppl = Frame(revbox, bg="#5B0A91")
revboxppl.place(relwidth=1, relheight=1)

#LABELS ON "reboxppl" FRAME
pathg="ill.png"
kl = Image.open(pathg)
kl = kl.resize((50, 50), Image.ANTIALIAS)
rimg = ImageTk.PhotoImage(kl)
l1 = Label(revboxppl, image=rimg, bg="#5B0A91")
l1.place(relheight=1, relwidth=0.3)
l2 = Label(revboxppl, image=rimg, bg="#5B0A91")
l2.place(relheight=1, relwidth=0.3, relx=0.345)
l3 = Label(revboxppl, image=rimg, bg="#5B0A91")
l3.place(relheight=1, relwidth=0.3, relx=0.696)

Revive label outside function <--image

expected output <--image

but when i used this segment inside my actual program the labels worked but the image ill.png was not added

Revive label defined inside function

actual output

Is it not possible to add an image inside function or am i just too dumb please help..

Salik Malik
  • 207
  • 1
  • 2
  • 15
  • 1
    Does this answer your question? [Why does Tkinter image not show up if created in a function?](https://stackoverflow.com/questions/16424091/why-does-tkinter-image-not-show-up-if-created-in-a-function) – jizhihaoSAMA Apr 04 '20 at 06:12
  • Yo it helped now its working thank you jizhihaosama – Salik Malik Apr 05 '20 at 07:38

0 Answers0