jeverling@gmail.com wrote:
Hello everybody!
I try to create an app that can be used on multiple platforms and
includes a wx.TextCtrl that acts as a drop target.The following code works fine on Windows:
"
import wxclass TextDropTarget(wx.TextDropTarget):
def __init__(self, obj):
wx.TextDropTarget.__init__(self)
self.obj = objdef OnDropText(self, x, y, data):
self.obj.WriteText(unicode(data) + '\n')class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
kwds["style"] = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL
wx.Frame.__init__(self, *args, **kwds)
self.text_ctrl_urls = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
dt1 = TextDropTarget(self.text_ctrl_urls)
self.text_ctrl_urls.SetDropTarget(dt1)if __name__ == "__main__":
app = wx.PySimpleApp(0)
frame_1 = MyFrame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
app.MainLoop()
"
However, in Linux it doesn't work. I tried with wxgtk 2.6, 2.8, python
2.4.4, 2.5.1, KDE and Gnome.
When the wx.TextCtrl is designated as drop-target, dropping doesn't work.
If not, it works (standard behaviour in KDE and GNOME).
I could of course check for the operating system and don't assign the
drop-target when running under Linux, but I think it would be better
if wxpython would also accept dropped text in wx.TextDropTargets out
of the box under linux.
Or is it just me?
FYI, you'll have a similar problem on Windows if you use one of the wx.TE_RICH style flags. Basically the problem is if the native widget handles DnD itself by default we have no way of turning it off. But since keeping the native things acting natively is a basic design principle of wxWidgets I doubt that we would want to.
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!