Search code examples
pythonqtcanopyenaml

How to get key events when using enaml?


I've been using enaml (0.6.8 which is what is available with Canopy for now) and have successfully created some very useful utility applications. I would like, however, to intercept keyboard events to enable some quick keyboard shortcuts rather than repetitive button-clicking in the UI.

How do I approach this? I understand that this will be toolkit (qt4) specific, but cannot really figure out where to begin. I've read some on event filters in qt, which seem like what I might want, but I do not understand the mechanisms for relating QApplication, etc. to enaml


Solution

  • Intercepting raw key events is not currently supported, unless you want to work directly with the toolkit widget via foo.proxy.widget (on the 0.7+ series; the 0.6 series is no longer supported). You can, however, define a MenuBar with Actions which support accelerator keys triggered by custom action names such as "Cut\tCtrl+C" and "Paste\tCtrl+V".