wxPython Drag and Drop exit code 139 crash
Question: I am experimenting with wxPython trying to learn drag and drop. Why doesn't
the following work on Linux? The app starts up, but when I drag the static
text into the text field, I get a 139 exit code with version 2.8 using python
2.7.

    
    
    import wx
    class DropTarget(wx.DropTarget):
        def __init__(self):
                wx.DropTarget.__init__(self)
                self.dataobject = wx.PyTextDataObject()
                self.SetDataObject(self.dataobject)
        def OnData(self, x, y, d):
                pass
    
    class Txt(wx.StaticText):
        def __init__(self, parent, label_):
                wx.StaticText.__init__(self, parent, label=label_)
                self.Bind(wx.EVT_LEFT_DOWN, self.handle)
        def handle(self, event):
                ds = wx.DropSource(self)
                d = wx.PyTextDataObject('some text')
                ds.SetData(d)
                ds.DoDragDrop(True)
    
    class MyFrame(wx.Frame):
        def __init__(self):
                wx.Frame.__init__(self, None, -1, 'whatevs')
                main_panel = wx.Panel(self)
    
                txt = Txt(main_panel, 'ONE')
                txt2 = wx.TextCtrl(main_panel)
    
                s = wx.BoxSizer(wx.VERTICAL)
                s.Add(txt)
                s.Add(txt2)
                main_panel.SetSizer(s)
    
                dt = DropTarget()
                txt2.SetDropTarget(dt)
    
    
    if __name__ == '__main__':
        app = wx.App()
        MyFrame().Show(True)
        app.MainLoop()
    


Answer: Try replacing the line

    
    
            ds = wx.DropSource(self)
    

with

    
    
            ds = wx.DropSource(self.GetParent())
    

I was able to reproduce the crash you are seeing, but once I made the above
change the crash went away.

It seems that for some reason, wx doesn't like instances of `wx.StaticText`
(or subclasses of it in your case) being passed to the `wx.DropSource`
constructor. I'm not sure why.

I changed your code so that `Txt` derived from `wx.TextCtrl` instead of
`wx.StaticText` and I couldn't reproduce the problem any more. I also tried
playing around with the first sample program found on
<http://wiki.wxpython.org/DragAndDrop>, and found that I could make it crash
if I set the drop source to be one of the `StaticText` objects this code
creates instead of a `TextCtrl`.

If there's anything in the wxWidgets or wxPython documentation that says you
can't use a `wx.StaticText` as a drop source, I didn't find it. It certainly
wasn't obvious to me. (The [documentation for
wxDropSource](http://docs.wxwidgets.org/trunk/classwx_drop_source.html) says
that you pass to each constructor

> The window which initiates the drag and drop operation.

However, there doesn't appear to be any restriction on the types of 'window'
(or 'widget') that you can use as a drop source.)

