Problem with drag and drop using gizmo tree list control

Hi,

I am able to get drag and drop working properly using the standard wx.TreeCtrl. But if I use the gizmo tree list control, drag and drop malfunctions. The following code makes it easy to see the impact of using the different tree controls.

Firstly, test the code with a standard tree control, i.e. use_gizmo_version = False (line 11 or so). Drag and drop should work flawlessly with correct information being printed out. If you reset use_gizmo_version to True, however, you should experience some odd behaviour.

Problems occur in both Windows XP and Ubuntu Intrepid Ibex.

I experimented with the full row highlight setting but I think the problem happens either way. NB the behaviour is variable but if you try repeated drag and dropping you should experience issues.

Is there something I am doing incorrectly or is this a bug/unexpected behaviour etc?

···

------------------------------------------------------------------------------------------------------------------------------

import wx
import wx.gizmos

class MainWindow(wx.Dialog):
    def __init__(self,parent,id,title):
        # Create a Dialog Box
        wx.Dialog.__init__(self, parent, -1, title,
                           size = (320,600),
                           style=wx.DEFAULT_FRAME_STYLE)
        # setup tree
        use_gizmo_version = False
        if use_gizmo_version:
            use_full_row_highlight = False # if true, weird behaviour occurs
                # NB may take several drags for the problems to become apparent
            if use_full_row_highlight:
                self.tree = wx.gizmos.TreeListCtrl(self, -1,
                                    style=wx.TR_FULL_ROW_HIGHLIGHT,
                                    size=(200, 200))
            else:
                self.tree = wx.gizmos.TreeListCtrl(self, -1,
                                        size=(200, 200))
            self.tree.AddColumn("Name")
            self.tree.AddColumn("Empty")
        else:
            self.tree = wx.TreeCtrl(self, -1,
                                    style=wx.TR_HAS_BUTTONS,
                                    size=(200, 200))
        self.treeroot = self.tree.AddRoot("I am the root")
        self.tree.AppendItem(self.treeroot, "Alfie")
        self.tree.AppendItem(self.treeroot, "Boris")
        self.tree.AppendItem(self.treeroot, "Charlie")
        self.tree.AppendItem(self.treeroot, "Dave")
        self.tree.AppendItem(self.treeroot, "Elliot")
        self.tree.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnBeginDrag)
        self.tree.Bind(wx.EVT_TREE_END_DRAG, self.OnEndDrag)
        #self.tree.Expand(self.treeroot) # no difference
        # misc form layout and close button
        self.btnClose = wx.Button(self, -1, "Close")
        self.btnClose.Bind(wx.EVT_BUTTON, self.OnClose)
        szrMain = wx.BoxSizer(wx.VERTICAL)
        szrMain.Add(self.tree, 1, wx.GROW)
        szrMain.Add(self.btnClose, 0)
        self.SetSizer(szrMain)
        self.Fit()
                       def OnBeginDrag(self, event):
        event.Allow()
        print "Beginning drag"
        drag_item = event.GetItem()
        print "Dragging '%s'" % self.tree.GetItemText(drag_item)

    def OnEndDrag(self, event):
        print "Ending drag"
        target_item = event.GetItem()
        print "Dragging to '%s'" % self.tree.GetItemText(target_item)

    def OnClose(self, event):
        self.Destroy()

class MyApp(wx.App):
    def OnInit(self):
        frame = MainWindow(None, -1, "Drag and Drop Test")
        self.SetTopWindow(frame)
        frame.CentreOnScreen()
        frame.Show()
        return True

app = MyApp()
app.MainLoop()

-----------------------------------------------------------------------------------------------------------

All the best, Grant

Grant Paton-Simpson wrote:

Hi,

I am able to get drag and drop working properly using the standard wx.TreeCtrl. But if I use the gizmo tree list control, drag and drop malfunctions. The following code makes it easy to see the impact of using the different tree controls.

Firstly, test the code with a standard tree control, i.e. use_gizmo_version = False (line 11 or so). Drag and drop should work flawlessly with correct information being printed out. If you reset use_gizmo_version to True, however, you should experience some odd behaviour.

Problems occur in both Windows XP and Ubuntu Intrepid Ibex.

I experimented with the full row highlight setting but I think the problem happens either way. NB the behaviour is variable but if you try repeated drag and dropping you should experience issues.

Is there something I am doing incorrectly or is this a bug/unexpected behaviour etc?

Probably bugs. They are totally separate implementations so it's not surprising that they have diverged somewhat over time.

···

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