Peter Milliken wrote:
I have gone around and around on this one for several days now trying to
find a satisfactory answer. Basically, I have identified three possible
"solutions"/routes to some resolution of my problem. These are:1. Use of Accelerator Tables - but I don't understand the Accelerator Event
documentation i.e. why does a key code sequence have to be "linked" to a
"menu or control command identifier"? Why can't that third argument be a
function rather than an id? What is a "control command identifier" BTW? Does
using an accelerator table mean that I have to have a menu item/control
command for every hot key I wish to define?
In a nutshell, since an accelerator is normally used for a menu item the system emits an EVT_MENU event when the key is pressed. So to catch it you just have to define the accelerator item with a unique id (just as you would if you were making a menu item) and then bind that ID to a handler with EVT_MENU.
2. the EventManager Class in lib/evtmgr.py - again, there was insufficient
explanation/example to work out how to use it for my purposes (even though
the commentary states that its purpose is to be "An easier, more "Pythonic"
and more OO method of registering handlers for wxWindows events using the
Publish/Subscribe pattern" :-)).
Did you read the doc strings at the begining of the module?
3. "Pluggable event handlers" - I can't understand sufficient information
from the Event Handling overview or find any reasonable example of their
use. These later seem more like where I need to go, but I can't find any
code that makes use of it and the reference material isn't really much help
in trying to work out how they are used (well, that I can find :-)).
This is really just a crutch for C++ users since C++ isn't as dynamic as Python.
Basically it allows you to change the event handling behaviour of window classes without having to derive a new class from the window class. For example, if you wanted to add a certain behaviouir to wxButton, wxTextCtrl, and wxComboBox then in C++ you can either derive new versions of each of those classes or derive a single class from wxEvtHandler and use PushEventHandler to add an instance of it to your button textctrl and combo. In Python all you have to do is hook the event in question for each control to a single handler since handlers don't have to be members of the class that receives the event.
ยทยทยท
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!