event handler advice
Robert Vollmert
rvollmert at gmx.net
Tue Jul 18 04:52:04 EDT 2000
On Mon, Jul 17, 2000 at 03:49:02PM -0700, Pete Shinners wrote:
> my guess is i need some dictionary that defines the
> messages and their routine name (no shortcut way to do
> this unless python had #define like macros :])
>
> messages = {msg.INIT:"INIT", msg.PLAY:"PLAY", ...etc}
You could try to generate this dictionary automatically. Something
like
messages = {}
for name in dir(msg):
val = getattr(msg, name)
if type(val) == type(0):
messages[val] = name
maybe with some additional testing of the format of name, so you don't
by accident define a signal to call __doc__ or the like.
--
Robert Vollmert rvollmert at gmx.net
More information about the Python-list
mailing list