How source object can receive feedback information of object at dropping moment (DataSource)?
I have one window - EditWindow ( object of class, which is inherit wx.Frame ), which contain Grid object (self.grid). In this class i write this method:
def OnSubindexGridCellLeftClick( self, event ):
....
dragSource = MyDropSource( self.grid )
dragSource.SetData( data )
dragSource.DoDragDrop()
event.Skip()
and bind it in __init__
of EditWindow :
self.grid.Bind( wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnSubindexGridCellLeftClick )
in the another window - "VariableWindow" i have got a another grid - "VariablesGrid" and i determine the following class:
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)
....
In the another window i set drop target:
self.VariablesGrid.SetDropTarget(VariableDropTarget(self))
开发者_JAVA技巧
How i can hook some information of object - "VariablesGrid" at the moment, when i drop cursor from grid (which is situated in EditorWindow). I want to take information of data in VariablesGrid and how EditWindow can receive this information ? sorry for my bad English.
You could use pubsub to send the data to the EditorWindow and then display it. Do the sending in the OnDropText method only so it only sends when you actually drop at the end of the drag. Here's a simple tutorial on pubsub to get you going: http://www.blog.pythonlibrary.org/2010/06/27/wxpython-and-pubsub-a-simple-tutorial/
Let's see if I understand the question.
You have a 'drag and drop' source window and a 'drag and drop' destination window. You want to pass some information from the destination window to the source window when the user performs a drag and drop.
Is that correct?
In general, this cannot be done. The information flow is from the source to the destination, as suggested by the names.
However, if the source and destination are in the same running application, you can 'fake' it by having the destination call a method in the source, passing the required information from the destination to the source, when the drop is completed.
If you do this, you should ensure that only a single instance of the application can run, otherwise chaos will result if the user drags and drops between two copies of the application.
精彩评论