I have a drop source and multiple drop targets. Is there a way to determine the target without passing it as an argument.
Here's the code as implemented.
class Controller(object):
def __init__(self):
self.tree1 = app.mainFrame.tree1
self.tree2 = app.mainFrame.tree2
dt1 = MyDropTarget(tree=self.tree1) #don't want to pass self.tree1
self.tree1.SetDropTarget(dt1)
dt2 = MyDropTarget(tree=self.tree2) #don't want to pass self.tree2
self.tree2.SetDropTarget(dt2)
class MyDropTarget(wx.TextDropTarget):
def __init__(self, target): # don't want to pass target
super(MyDropTarget, self).__init__()
self.target= target
def OnDropText(self,x,y,data):
print "successful drop",x,y
selectedItem,flags = self.target.HitTest((x,y)) #don't want to use data member
It feels like there should be a way from the drop target itself, to tell what window it is attached to
but I haven't figured it out.
It works as written, it just seems to be better style and more general to determine it dynamically. For instance if
each tab in a notebook had it's own drop target.
Danny