新手写了一段程序,显示图片,程序不报错,但显示不出图片,不知道为什么,请教!
程序代码:
import tkinter as tk from tkinter import * from PIL import Image,ImageTk class pic(Canvas): i=0 j=0 n=0 def __init__(self,fr,i,j): Canvas.__init__(self,fr) self.i=i self.j=j self.put(0,0) def put(self,bw,n): img0=Image.open("0.jpg") img1=Image.open("1.jpg") img2=Image.open("2.jpg") im0=ImageTk.PhotoImage(img0) im1=ImageTk.PhotoImage(img1) im2=ImageTk.PhotoImage(img2) self.create_image(300,200,image=im0) frame=tk.Tk() b1=pic(frame,0,0) b1.pack() frame.mainloop()