为什么我按下按键后没有不显示图片呢?

代码如下

[Copy to clipboard] [ - ]
CODE:
import os,sys,math,random,time  
from glob import glob   

#from time import sleep
from Tkinter import *   
import Image   
from ImageTk import PhotoImage

def ran():
  num = random.randint(1,44)
  print num
  try:
    imgpath = "pic/" + str(num) + ".JPG"
    print imgpath
    img = PhotoImage(file=imgpath)
    canvas.create_image(0,0,image=img,anchor="nw")
  except IOError:
    showerror('Photos',"This file isn't image.")
    pass

#=======init======#
top = Tk()
b1 = Button(top,text='start',command=ran)
b1.pack(side='left')
canvas = Canvas(top)
canvas.config(width=1024,height=768)
#img = PhotoImage(file="pic/12.jpg")
canvas.pack(side='top',expand='YES',fill='both')
#canvas.create_image(0,0,image=img,anchor="nw")
#imglist = [img for img in os.listdir('./pic')]
#==================#


top.mainloop()