Code: Alles auswählen
from Tkinter import *
import Image, ImageTk
class MyClass(Frame):
def __init__(self, parent, master=None):
Frame.__init__(self, master)
self.grid()
im = Image.open('hw1.pgm') # actually in dir: hw.jpg , hw0.jpg , hw1.pgm
im.thumbnail((280, 300), Image.ANTIALIAS)
self.photo = ImageTk.PhotoImage(im) # <--
Button(root,text="Quit",command=self.quit).pack()
Button(root,text="Bild",command=self.show_n).pack()
def show_n(self):
Label(root, image=self.photo).pack() # <--
root=Tk()
root.title("Thumbnail")
my_class = MyClass(root)
root.mainloop()