draggable listbox?

i’m looking for a listbox-like widget that will let me
drag re-order items in it. ideally with some sort of visual cue as to where
the item being dragged will end up.

I can’t seem to find one in the standard wxpython
distro, does anyone know of one that exists already?

thanks.

Hamish McKenzie wrote:

i’m looking for a listbox-like widget that will let me drag re-order items in it. ideally with some sort of visual cue as to where the item being dragged will end up.

I can’t seem to find one in the standard wxpython distro, does anyone know of one that exists already?

It's not quite what you want (no DnD but has move up/down buttons instead) but have you looked at EditableListBox? It's just a layer added on to wx.ListCtrl so it probably wouldn't be too hard to duplicate what it does in Python and then add DnD abilities too.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

yeah I have seen that. buttons take up too much real estate, and are clunky for large lists.

thanks though.

···

-----Original Message-----
From: wxpython-users-bounces@lists.wxwidgets.org [mailto:wxpython-users-bounces@lists.wxwidgets.org] On Behalf Of Robin Dunn
Sent: Wednesday, April 29, 2009 8:07 PM
To: wxpython-users@lists.wxwidgets.org
Subject: Re: [wxpython-users] draggable listbox?

Hamish McKenzie wrote:

i'm looking for a listbox-like widget that will let me drag re-order
items in it. ideally with some sort of visual cue as to where the item
being dragged will end up.

I can't seem to find one in the standard wxpython distro, does anyone
know of one that exists already?

It's not quite what you want (no DnD but has move up/down buttons
instead) but have you looked at EditableListBox? It's just a layer
added on to wx.ListCtrl so it probably wouldn't be too hard to duplicate
what it does in Python and then add DnD abilities too.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Here is a simple Drag and Drop List Box. There is no indication of
where the item will drop, and I shouldn't use a TextDropObject and
TextDropTarget, but it's easier for me at my level.

import wx

class DropList(wx.ListBox, wx.TextDropTarget):
    def __init__(self, *args, **kw):
        wx.ListBox.__init__(self, *args, **kw)
        wx.TextDropTarget.__init__(self)
        self.SetDropTarget(self)

        self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)

    def OnDropText(self, x, y, text):
        string = self.GetString(int(text))
        self.Delete(int(text))
        if self.HitTest((x, y)) == wx.NOT_FOUND:
            self.Append(string)
        else:
            self.Insert(string,self.HitTest((x, y)))
        return wx.DragCopy

    def OnLeftDown(self, event):

        if self.HitTest(event.GetPosition()) != wx.NOT_FOUND:
            print self.GetString(self.HitTest(event.GetPosition()))
            dropSource = wx.DropSource(self)
            data = wx.PyTextDataObject(str(self.HitTest(event.GetPosition())))
            dropSource.SetData(data)

            res = dropSource.DoDragDrop(wx.Drag_CopyOnly)

···

On 4/30/09, Hamish McKenzie <hamish@valvesoftware.com> wrote:

yeah I have seen that. buttons take up too much real estate, and are clunky for large lists.

thanks though.

-----Original Message-----
From: wxpython-users-bounces@lists.wxwidgets.org [mailto:wxpython-users-bounces@lists.wxwidgets.org] On Behalf Of Robin Dunn
Sent: Wednesday, April 29, 2009 8:07 PM
To: wxpython-users@lists.wxwidgets.org
Subject: Re: [wxpython-users] draggable listbox?

Hamish McKenzie wrote:
> i'm looking for a listbox-like widget that will let me drag re-order
> items in it. ideally with some sort of visual cue as to where the item
> being dragged will end up.
>
>
>
> I can't seem to find one in the standard wxpython distro, does anyone
> know of one that exists already?

It's not quite what you want (no DnD but has move up/down buttons
instead) but have you looked at EditableListBox? It's just a layer
added on to wx.ListCtrl so it probably wouldn't be too hard to duplicate
what it does in Python and then add DnD abilities too.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

--
Josh English
Joshua.R.English@gmail.com