Rebinding menu items in wxPython

Travis Nixon tnixon at avalanchesoftware.com
Tue Apr 24 16:46:00 EDT 2001


After spending most of today and yesterday trying to figure out why my
module reloading wasn't working, I eventually came to the conclusion that
calling EVT_MENU a second time on the same id doesn't actually change
anything.

Say for example, I have a menu item that calls a particular function, and I
want to change it on the fly to call another function instead, and you'll
just have to trust me that I have a good reason to do this thing that sounds
rather insane.  :)

Instead of doing this:

    EVT_MENU( frame, id, command )

I have to do this:

    frame.Disconnect( id, -1, wxEVT_COMMAND_MENU_SELECTED )
    EVT_MENU( frame, id, command )

Why do I have to force a disconnect first?  And more importantly, is there
some set of documentation somewhere that would have told me how to do this,
or at least giving me some idea of what to even consider doing, other than
tracing through the sources and figuring out what's really going on?  It was
really quite hairy trying to figure out why it wasn't working in the first
place, and once I figured out where the problem really was (my dynamic
module reloading code seems to work just fine after all) it took me forever
to figure out that Disconnect is what I wanted, and even longer to figure
out exactly what arguments to pass to Disconnect.





More information about the Python-list mailing list