On Dec 16, 2005, at 8:03 PM, Don Taylor wrote:
> Is there a list somewhere of which events can be handled by the
> Background? Or, which code should I look at to fiigure this out?
>
> Thanks,
>
> Don.
>
There isn't a specific list of background events that is up-to-date so
I'll list them here until the docs are fixed:
Events for the background (defined in model.py):
activate
deactivate
initialize
idle
close
maximize
minimize
restore
move
size
The easiest way to see these in action is to run a sample with the
Message Watcher window open. Note that since "idle" in wxPython simply
means that there are no more events in the event queue the 'idle' event
is not actually displayed in the message watcher window as it can cause
some problems during program exit and other places where events are
still firing but window handles no longer exist, which can cause a
crash. In addition, due to the way events fire when a window is first
created, you won't see some of the other initial events. You might want
to run the testevents sample to see some of these or check differences
between platforms in event firing.
It is also possible to have a generic "background" handler for multiple
components rather than a specific one for each component. This is used
in several places within the samples and tools of PythonCard, but the
tictactoe sample has a handler specifically to show this off with a
generic
def on_mouseUp(self, event):
as well as a
def on_btn0_mouseUp(self, event):
All, components that generate mouseUp events but don't have their own
handlers such as the btn0 one above end up using the on_mouseUp
handler. There is code in the on_mouseUp handler to make sure that it
only deals with buttons it was intended for like so:
def on_mouseUp(self, event):
# make sure that we only handle a mouseClick for
# the ImageButtons on the playfield
if self.isPlayfieldButton(event.target):
...
else:
event.skip()
When PythonCard loads a background it auto-binds events. The way this
works is that it searches for an event handler in your code of the form
on_componentName_eventName and if it finds one then it binds that event
handler to your component, then it searches for one of the form
on_eventName and binds that handler. If no handler exists, then the
native event is simply passed up the event chain and handled by
wxPython normally.
ka
|