我有一個窗口 - EditWindow(類的對象,它是繼承wx.Frame),它包含Grid對象(self.grid)。 在這個類我寫這個方法:源對象如何在下落時刻接收對象的反饋信息(DataSource)?
def OnSubindexGridCellLeftClick(self, event):
....
dragSource = MyDropSource(self.grid)
dragSource.SetData(data)
dragSource.DoDragDrop()
event.Skip()
和EditWindow的__init__
其綁定:
self.grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnSubindexGridCellLeftClick)
在另一個窗口 - 「VariableWindow」我有我的另一格 - 「VariablesGrid」和我確定以下類:
class VariableDropTarget(wx.TextDropTarget):
def __init__(self, parent):
wx.TextDropTarget.__init__(self)
self.ParentWindow = parent
def OnDropText(self, x, y, data):
x, y = self.ParentWindow.VariablesGrid.CalcUnscrolledPosition(x, y)
....
在另一個窗口我設置放置目標:
self.VariablesGrid.SetDropTarget(VariableDropTarget(self))
當我從網格中刪除光標(位於EditorWindow中)時,如何鉤住對象的一些信息 - 「VariablesGrid」。我想獲取VariablesGrid中的數據信息以及EditWindow如何接收這些信息? 對不起我的英文不好。
正如ravenspoint指出的那樣,只有在應用程序中拖動某些東西時,此解決方案纔會起作用,這正是我認爲您所說的要做的事情。如果你在應用程序外部拖動,那麼我無法做到這一點,我知道。 –