From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Tuesday, October 02, 2007 2:39 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] wxGrid navigation and column tooltips
Mike Driscoll wrote:
> Hi,
>
> I have a wx.Grid that I'm using for as a spreadsheet in one of my
> applications. I would like to override the grid cell editor's arrow
> key navigation so that when I press one of the keys, it
will navigate
> away from the cell I am currently editing, like MS Excel
does. While I
> can successfully catch the keycodes for the buttons when I am not
> editing a cell, they seem to get eaten once I actually activate the
> editor. Is there a way to do this?
Keep in mind that when the cell editor is shown that there is
another widget there, and so the grid itself doses not have
the keyboard focus anymore, and so it will not be getting the
key events. You can however bind your own key handler to the
cell editor widget and take care of things there. Bind a
handler for the EVT_GRID_EDITOR_CREATED event and in the
handler you can use event.GetControl() to get a reference to
the widget.
This worked exactly as described. I figured the editor was some kind of
"sub-widget" or something. Thanks!
>
> Also, one of my users asked if I could put pop-up tooltips on the
> column name when moused over. I can't find anything about
mouse-over events.
You can intercept the mouse events for the
theGrid.GetGridColLabelWindow() and show a tip window if you
sense that the mouse is hovering. Be sure to call
event.Skip() so the default event handlers in the grid will
still be called.
I almost have this, but I must still be missing something. I am currently
binding my grid to EVT_GRID_LABEL_LEFT_CLICK and then using the following
handler:
def onColClick(self, event):
colNum = event.GetCol()
col_dict = {1:'Column 1', 2:'Column 2'}
self.myGrid.GetGridColLabelWindow().SetToolTipString(col_dict[colNum])
event.Skip()
This works for left-clicking the column only. I tried to bind to
EVT_MOTION and EVT_ENTER_WINDOW, but those don't seem to work with the
grid since they're not grid specific events.
Thanks for any tips.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
Mike
···
-----Original Message-----