lundi 30 mars 2015

Background Image in python34 Is not appearning on run time

Can anyone please help me here. I am using python34 and the below mentioned code cnippet does not yield any interpretaion error. But it does not show the picture when run.



import tkinter as tk
from PIL import ImageTk



class MyApp(Frame):
def __init__(self,parent):
Frame.__init__(self,parent)
self.parent=parent
self.createUI()

def createUI(self):
self.grid()
raw_data=Image.open("abc.gif")
image = ImageTk.PhotoImage(raw_data)
label=tk.Label(image = image)
label.grid(column=0,row=0)


root=tk.Tk()
app=MyApp(root)
app.mainloop()


although the following code works fine. import tkinter as tk from PIL import ImageTk import urllib.request



root = tk.Tk()

raw_data=Image.open("abc.gif")
image = ImageTk.PhotoImage(raw_data)
label = tk.Label(image=image)
label.pack()
tk.mainloop()


PLease sugest what I am missing or doing wrong.


Aucun commentaire:

Enregistrer un commentaire