Insert image to a List box

Matt McCredie mccredie at gmail.com
Fri Nov 16 16:40:10 EST 2007


> Thanks a lot for your patience.
> I put the gif file to a folder called fig in my desktop.
> dirpath = './fig'
> still got error:
>
> Traceback (most recent call last):
>   File "11.py", line 238, in <module>
>     img.config(image=gifsdict[imgname])
> NameError: name 'imgname' is not defined
>

You should reply to the python list. That way everyone gets the
benefit of your questions.

The problem is here:
[code]
def list_entry_clicked(*ignore):
   imgname = L.get(L.curselection()[0])
img.config(image=gifsdict[imgname])
L.bind('<ButtonRelease-1>', list_entry_clicked)
[/code]

I think the main problem is that the line
`img.config(image=gifsdict[imgname])' is supposed to be part of
`list_entry_clicked' and it isn't.

What you want to do (maybe? I made some assumptions):
[code]
def list_entry_clicked(*ignore):
   imgname = L.get(L.curselection()[0])
   img.config(image=gifsdict[imgname])

L.bind('<ButtonRelease-1>', list_entry_clicked)
[/code]

That _should_ work, but it is untested.

Matt



More information about the Python-list mailing list