I think this is largely a question of elegance, but I can't seem to see
what the "accepted approach" is here.
Suppose I have an event handler on (say) a ListBox, and this event handler
updates some other window when an item is added to or deleted from the
ListBox. So the "prototype" for the handler looks like 'Update(self,
event)'.
Now suppose that there are other circumstances when I want to invoke this
handler -- like when I programmatically alter the list and reset the
selection (in which case the wxEVT_COMMAND_LISTBOX_SELECT event does not
get emitted). (One could argue that there could be an option on these
methods to emit the event, but let's not go there now. I'm sure there are
arguments on both sides of that issue.)
So what is the "elegant" thing to do?
1. Just call the method directly with 'None' as the second (event)
parameter?
2. Create a fake event object and call the method with it as the second
parameter?
3. Force the emission of the event.
There's not too much point (in general) in doing 2 since it doesn't gain
you anything over 1 and just takes more time. Choice 3 was my first
inclination, but I can't seem to figure out how (after looking through the
demos and my stack of Python doc) to force an event emission. 1 will do
the job, but it seems -- I don't know -- somehow a bit tacky.
···
--------------------------------------
Gary H. Merrill
Director and Principal Scientist, New Applications
Data Exploration Sciences
GlaxoSmithKline Inc.
(919) 483-8456