I have a class MyGrid which is derived from wx.Grid. In Refresh() it uses the
AppendRows() and SetCursor() methods which each raise an EVT_GRID_SELECT_CELL
event. A panel which uses MyGrid listens to EVT_GRID_SELECT_CELL event.
My problem is, that MyGrid should get the event if it is raised durng a refresh.
Is there a way to temporarily disable event raising?
Use a boolean variable «bIgnore» visible at grid level.
In Refresh() write:
self.bIgnore =True
Then override the handler of EVT_GRID_SELECT_CELL, and in On_EVT_GRID_SELECT_CELL(self, event) write:
if self.bIgnore:
self.bIgnore = False
return
else:
DoWhatNormallyRequested
I have a class MyGrid which is derived from wx.Grid. In Refresh() it uses the
AppendRows() and SetCursor() methods which each raise an EVT_GRID_SELECT_CELL
event. A panel which uses MyGrid listens to EVT_GRID_SELECT_CELL event.
My problem is, that MyGrid should get the event if it is raised durng a refresh.
Is there a way to temporarily disable event raising?
You could try calling SetEvtHandlerEnabled(False) on the window that you want to not get events, but I think most people usually just use a flag in the handler like Raffaello suggested as it is more easily understandable and more flexible in other situations.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!