Tkinter/Listbox question

Fredrik Lundh fredrik at pythonware.com
Tue May 11 07:15:20 EDT 1999


David Miller wrote:
> I need to have a scrolling listbox have drag-and-drop
> reordering of the list.  From the manpage:
> 
> /.../
> In browse mode it is also possible to drag the selection
> with button 1.
> /.../

"drag the selection" means "drag the selection",
not "drag and drop reordering of the list".

Tk doesn't support drag and drop at all (but look
in the lib-tk/Tkdnd.py module for one way to do
it).

you might also be able to get something useful by
adding some custom bindings

(hint:

    i = int(listbox.index("@%d,%d" % (x, y)))

returns the list item index closest to the given
mouse coordinate.  "grab" that item on <Button-1>,
and update the list on each <B1-Motion> event)

</F>





More information about the Python-list mailing list