László Nagy wrote:
Opps, works only if you pass it to Bind too:
self.GetGridWindow().Bind(
wx.EVT_MOTION,
self.OnMotion,
self.GetGridWindow()
)
Yep, see my second message which also does the trick.
But how do you know of this? GetGridWindow is not documented (at least not on the wxPython docs installed with 2.6).
What is GetGridWindow?
Nope, it isn't documented anywhere I can find either, other than in "import wx.grid;help(wx.grid.Grid.GetGridWindow)". I know of it only after innumerable sessions of whacking my head and pulling my hair out trying to wrestle wx.Grid down to something I could use for Dabo's dGrid control, which provides a much simpler and easier to use interface. For example, to do the motion binding in Dabo's dGrid, you would issue:
grid.bindEvent(dEvents.GridMouseMove, self.onMotion)
and dGrid works out which wx event to bind to, in this case binding to the undocumented GetGridWindow() object.
For completeness sake, there are a few of these underdocumented windows:
GetGridColLabelWindow:
the "Header". In Dabo, it is expressed as grid.Header
GetGridCornerLabelWindow:
I can only guess it is the intersection between rows and columns, that little thing in the corner. I suppose you could put some text or an icon there or something.
GetGridRowLabelWindow:
The vertical window that comprises the row labels.
GetGridWindow:
The actual window where the grid cells are drawn.
The "Grid" is really a container of the above windows, and as such won't always receive events that are generated from the child windows.
Everything I say here is based 100% on observation. I've never looked at the wxPython or wxWidgets source.
···
--
Paul McNett
http://paulmcnett.com
http://dabodev.com