hotkey control

Greetings,

I have scoured high and low for this information, so I'm guessing what I'm about to ask can't currently be done in WXPython. In straight Win32, one can create an input field for capturing hotkeys with the WM_HOTKEY class. I am wanting to give the users of our app an easy way to customize some global commands, but I'm not finding a WX analog. If the Win32 way is the only way to go, is it possible to create a form in Win32 and embed it inside a WXPython container?

Thanks,
Steve

Are you talking about hotkeys inside your wxPython application or are you trying to bind keys to the OS level? If it’s just for your program, look into the AcceleratorTable:

http://www.blog.pythonlibrary.org/2010/12/02/wxpython-keyboard-shortcuts-accelerators/

On Windows, you can use PyWin32 and ctypes to accomplish the latter: http://timgolden.me.uk/python/win32_how_do_i/catch_system_wide_hotkeys.html

···

Mike Driscoll

Blog: http://blog.pythonlibrary.org

Thanks, Mike. My goal is to implement system-wide hotkeys in the app itself. Hard-wiring them is very straight-forward, but I also want to give our users the ability to change the commands if they want to. The control I am wanting to add in my app is the hotkey edit field (which you can find in the Shortcut tab of a Windows Desktop icon). Again, this is relatively easy in straight Win32, but I am coming to the realization that WX may be defficient here.

Steve

···


Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Mike Driscoll kyosohma@gmail.com wrote:

Are you talking about hotkeys inside your wxPython application or are you trying to bind keys to the OS level? If it’s just for your program, look into the AcceleratorTable:

wxPython: Keyboard Shortcuts (Accelerators) - Mouse Vs Python

On Windows, you can use PyWin32 and ctypes to accomplish the latter: Tim Golden's Python Stuff: Catch system-wide hotkeys


Mike Driscoll

Blog: http://blog.pythonlibrary.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

You may be able to do it by catching EVT_KEY_DOWN and EVT_CHAR. Here’s a tutorial on the subject: http://www.blog.pythonlibrary.org/2009/08/29/wxpython-catching-key-and-char-events/

But yes, it isn’t always easy.

···

On Mon, Oct 24, 2011 at 4:39 PM, Stephen Clower stephen.clower@gmail.com wrote:

Thanks, Mike. My goal is to implement system-wide hotkeys in the app itself. Hard-wiring them is very straight-forward, but I also want to give our users the ability to change the commands if they want to. The control I am wanting to add in my app is the hotkey edit field (which you can find in the Shortcut tab of a Windows Desktop icon). Again, this is relatively easy in straight Win32, but I am coming to the realization that WX may be defficient here.

Steve


Mike Driscoll

Blog: http://blog.pythonlibrary.org

Greetings,

I have scoured high and low for this information, so I'm guessing what
I'm about to ask can't currently be done in WXPython. In straight Win32,
one can create an input field for capturing hotkeys with the WM_HOTKEY
class. I am wanting to give the users of our app an easy way to
customize some global commands, but I'm not finding a WX analog.

There isn't one, but I expect that it would not be too terribly hard to do, as Mike suggested, by catching the key down and up events and modifying the content of a read-only text ctrl to match the key states.

If the
Win32 way is the only way to go, is it possible to create a form in
Win32 and embed it inside a WXPython container?

Yes. You can get the Windows Handle for any window/widget (such as a wx.Panel) with GetHandle, and create your widget using native win32 API calls using that handle as the parent. There is also an example in the wiki of how to intercept the WndProc messages from a wx window if you need to do something like that.

···

On 10/24/11 1:25 PM, Stephen Clower wrote:

--
Robin Dunn
Software Craftsman