Tkinter create_image
<p>I've been working to get a simple Tkinter canvas to display an image using create_image.  I've read many threads that say that you need to create a reference to the object outside any function or class, otherwise the image object will be garbage collected.  Unfortunately, I still cannot get this to work.  Below is my code as it stands.  Ignore all the colors - I use them to illustrate where the frames and canvas live on the window.</p>

<p>-Kirk</p>

<pre><code>import Tkinter as tk
from PIL import Image
from PIL import ImageTk

imageList = []
image = Image.open('len_std.jpg')

#event handlers
def hit_sel_click():
    imageList = []
    test_image = ImageTk.PhotoImage(image)
    imageList.append(cnv_hits.create_image(0,0,
                 image=test_image))    

#start root
root = tk.Tk()
root.title('SimView')
root.resizable(width=False, height=False)

#target/control variables
hit_sel = tk.StringVar() #holds radio button with activity level

#build GUI
frm_hits = tk.Frame(root, height=800, width=200, bg='#FF0000')
frm_hits.grid(rowspan=3, sticky=tk.W+tk.N+tk.S+tk.E)

tk.Label(frm_hits, text='Activity:').grid()
tk.Radiobutton(frm_hits, text='Low', variable=hit_sel, value='Low',
               command=hit_sel_click).grid(sticky=tk.W)
tk.Radiobutton(frm_hits, text='Medium', variable=hit_sel, value='Medium',
                command=hit_sel_click).grid(sticky=tk.W)
tmp = tk.Radiobutton(frm_hits, text='High', variable=hit_sel,value='High',
                 command=hit_sel_click)
tmp.grid(sticky=tk.W)
tmp.select()

frm_hit_list = tk.Frame(frm_hits, bg='#002288')
frm_hit_list.grid(sticky=tk.W+tk.N+tk.E+tk.S)

scrl_hits = tk.Scrollbar(frm_hit_list, orient=tk.VERTICAL)
scrl_hits.grid(row=0, column=1, sticky=tk.N+tk.S)

cnv_hits = tk.Canvas(frm_hit_list, bg='#888800',width=200, height=200,
                     yscrollcommand=scrl_hits.set)
cnv_hits.grid(row=0, column=0, sticky=tk.W+tk.N+tk.E+tk.S)

scrl_hits.config(command=cnv_hits.yview)

root.mainloop()
</code></pre>