Tkinter To Display The Images
I am a newbie to python.I have a code where the image is not printed on the Tkinter.So please help me on how to display the image along with the Button and Textbox. Code: import Tk
Solution 1:
You have to save a reference to the photo image.
See this page for more information, or this one
There are numerous other problems with the code you posted, however; you need colons after function and class declarations, for example. When posting code, there's also no need for extraneous methods in the class, they only make it more difficult to understand
You also cannot mix managers or you're whole program might stall. This means you shouldn't be using pack and grid in the same program. Read through the effbot tutorial, it's really helpful!
class myproject(Tkinter.Tk):
def __init__(self,parent):
Tkinter.Tk.__init__(self)
self.image()
def image(self):
logo = Tkinter.PhotoImage(file='linux.gif')
self.logo = logo # You always need a reference to the image or it gets garbage collected
w1 = Tkinter.Label(self, image=logo).grid()
app = myproject(None)
app.mainloop()
Post a Comment for "Tkinter To Display The Images"