disable event raising

Hello!

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

···

2008/7/7 letij e6d8wtu02@sneakemail.com:

Hello!

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?


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

letij wrote:

Hello!

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!