I relatively recently discovered this and I start to use it quit a bit now.
Whenever I put some logging into such a handler I see that it is called a lot, so am a bit concerned on what overhead I am creating.
Googled to try and find some tips on what to do and what not to do in such handlers, besides the doc I haven't really found anything.
http://xoomer.virgilio.it/infinity77/Phoenix/UpdateUIEvent.html
Currently I use it to set the state of buttons and to handle a summary page in a dialog.
The buttons I do along these lines:
def onUpdateUI(self, evt):
event_id = evt.GetId()
if self.dbItem:
if event_id == self.create.GetId():
evt.Enable(False)
elif event_id == self.save.GetId():
evt.Enable(True)
...etc.
else:
if event_id == self.create.GetId():
evt.Enable(True)
elif event_id == self.translate.GetId():
evt.Enable(False)
elif event_id == self.save.GetId():
...etc.
Is this the correct way to do it? Can it be further optimized?
My summary page I do like this:
def setSummaryInfo(self, event):
event_id = event.GetId()
event_obj = event.GetEventObject()
c = self._controller
if event_id == c.eTotalFirstimp.GetId():
self.tFirstimp = c.eFirstimp.GetValue()
event_obj.SetValue(self.tFirstimp) # < ----- is this better then below?
elif event_id == c.eTotalSight.GetId():
self.tSight = c.eSight1.GetValue() + c.eSight2.GetValue() \
+ c.eSight3.GetValue() + c.eSight4.GetValue()
c.eTotalSight.SetValue(self.tSight) # < ------ or is this fine too?
... etc
Should I use constants instead of using GetId()?
Any other tips and/or links to documentation, tutorials etc.
Werner