After seeing this, PhotoImage not showing up the image associated with it I wondered why omitting the type of option does not throws an error instead of just not showing up the image?
This code does not show the image without throwing any error
import tkinter as tk
root = tk.Tk()
image1 = tk.PhotoImage("ban.gif")
tk.Label(root,image=image1).pack()
tk.Label(root, text="some string here").pack()
root.mainloop()
But this one works fine
import tkinter as tk
root = tk.Tk()
image1 = tk.PhotoImage(file="ban.gif")
tk.Label(root,image=image1).pack()
tk.Label(root, text="some string here").pack()
root.mainloop()
On effbot it doesn't say anything about it so I checked tcl man page for creating photos but still can not find why it behaves like this.
Also, if those two are duplicate ones, let me know so I will delete/close vote this one.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…