TkInter bind() event is not firing event trigger

MRAB python at mrabarnett.plus.com
Tue Jun 22 20:39:40 EDT 2010


Anthony Papillion wrote:
> So I want to execute some code when the user double clicks an item in
> a ListBox. The documentation says I should use the listbox.bind()
> method, specifying the Double-l event to detect the double left mouse
> button click. My code is this:
> 
> gsItems = Listbox(root, width=76, height=30, selectmode="browse",
> yscroll=scrollBar.set)
> gsItems.bind('<Double-l>', openandDisplayFolder)
> gsItems.pack()
> 
> So the first line configures the Listbox, second line SHOULD set up
> the event, and third line, of course, adds the Listbox to the UI.
> 
> The problem is that the openandDisplayFolder function is never
> executed. The function is VERY simple for now while I learn the way to
> do it:
> 
> def openandDisplayFolder(event):
>     tkMessageBox.showinfo("Event Fired", "An item has been double
> clicked!")
> 
> I've also removed the (event) parameter just in case and tried it and
> it makes no difference. What am I doing wrong here?
> 
According to:

 
http://www.pythonware.com/library/tkinter/introduction/events-and-bindings.htm

it's '<Double-Button-1>'.



More information about the Python-list mailing list