1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
import wx
class trURLDropTarget(wx.PyDropTarget):
def __init__(self, trWindow):
wx.PyDropTarget.__init__(self)
self.trWin = trWindow
self.data = wx.URLDataObject();
self.SetDataObject(self.data)
def OnDragOver(self, x, y, d):
return wx.DragLink
def OnData(self, x, y, d):
if not self.GetData():
return wx.DragNone
text = self.data.GetURL()
if text.count("\n") == 0 and text.find("://") != -1:
text = "<a href=\"" + text + "\"></a>"
self.trWin.updateTextBox(text, "insert")
return d
class trTextDropTarget(wx.PyDropTarget):
def __init__(self, trWindow):
wx.PyDropTarget.__init__(self)
self.do = wx.TextDataObject()
self.SetDataObject(self.do)
self.trWin = trWindow
def OnEnter(self, x, y, d):
#print "OnEnter: %d, %d, %d" % (x, y, d)
return wx.DragCopy
#def OnLeave(self):
#print "OnLeave"
def OnDrop(self, x, y):
#print "OnDrop: %d %d" % (x, y)
return true
def OnData(self, x, y, d):
#print "OnData: %d, %d, %d" % (x, y, d)
self.GetData()
#print "%s" % self.do.GetText()
self.trWin.updateTextBox(self.do.GetText())
return d
|