0

I have a window in Tkinter and there is a button on that window. when I click the button, I created another window(smaller, because this is like a dialog box).

I put a label in that dialog box,eg,"Save?" and then I added a picture just below the label.

The problem is ..the picture is not appearing and only a white box on the pink window is appearing.

why is this so?

This is the code:

dialog_wnd=Tk()
dialog_wnd.title("Email")
dialog_wnd.geometry("400x100")
dialog_wnd.configure(bg="pink")

label_dialog=Label(dialog_wnd,text="Save?",fg="purple",bg="pink")
label_dialog.pack()
label_dialog.place(x=120,y=3)
#putting a picture in dialog box
dialog_pic=ImageTk.PhotoImage(Image.open("pic.jpeg"))
dialog_pic_label=Label(dialog_wnd,image=dialog_pic)
dialog_pic_label.pack()
dialog_pic_label.place(x=200,y=8)
Stop harming Monica
  • 12,141
  • 1
  • 36
  • 56
Blue Berry
  • 107
  • 1
  • 2
  • 7
  • if you have this code in function then it can be problem with `"garbage collector"` - see `"Note"` at the end of page http://effbot.org/tkinterbook/photoimage.htm – furas Nov 25 '16 at 10:07
  • Thank you. I assign the image to a widget attribute and it's now working. – Blue Berry Nov 25 '16 at 10:26

0 Answers0