How to add a boss key into a wxPython application?

I have asked it a month ago on IRC but no one seemed to know if there is a way to add a boss key into a wxPython application.

[Boss Key = a combination of keys to hide and restore all windows related to the application]

using Show()\Hide() won’t help here because it only works when the focus is on the window so restoring the window is impossible. I’m not sure if its a windows feature only or perhaps its also possible with other OS.

Have anyone ever add something like that for an application?

Is there any example out there?

I hope it is possible and not too complicated (but I guess it does :expressionless: ).

Thanks :slight_smile:

roee88 shlomo wrote:

I have asked it a month ago on IRC but no one seemed to know if there is a way to add a boss key into a wxPython application.
[Boss Key = a combination of keys to hide and restore all windows related to the application]
using Show()\Hide() won't help here because it only works when the focus is on the window so restoring the window is impossible. I'm not sure if its a windows feature only or perhaps its also possible with other OS.
Have anyone ever add something like that for an application?

I've never tried it but you may want to try wx.Window.RegisterHotKey. You give it an ID, the modifiers and the key to watch for. When that key is pressed then the window gets a EVT_HOTKEY event with that ID.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Many thanks, this is working great.

Just a little question. what should hotkeyid be?

I’m currently using wx.NewId() for it, but I believe this is wrong.

hotkeyid = wx.NewId()
self.RegisterHotKey(hotkeyid, wx.MOD_CONTROL, ord(‘H’))

One more thing, is there any page with details information about “keycode” for each key? I mean, how should I know how to refer to the key with ‘~’ if in my keyboard the same key is used for: “~” “`” and “;” ?

Should I use RegisterHotKey 3 times for each one of them?

Thanks again :slight_smile:

···

On 6/24/06, Robin Dunn robin@alldunn.com wrote:

roee88 shlomo wrote:

I have asked it a month ago on IRC but no one seemed to know if there is
a way to add a boss key into a wxPython application.

[Boss Key = a combination of keys to hide and restore all windows
related to the application]
using Show()\Hide() won’t help here because it only works when the focus
is on the window so restoring the window is impossible. I’m not sure if

its a windows feature only or perhaps its also possible with other OS.
Have anyone ever add something like that for an application?

I’ve never tried it but you may want to try wx.Window.RegisterHotKey
.
You give it an ID, the modifiers and the key to watch for. When that
key is pressed then the window gets a EVT_HOTKEY event with that ID.


Robin Dunn
Software Craftsman

http://wxPython.org
Java give you jitters? Relax with wxPython!


To unsubscribe, e-mail:
wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

roee88 shlomo wrote:

Many thanks, this is working great.
Just a little question. what should hotkeyid be?
I'm currently using wx.NewId() for it, but I believe this is wrong.

No, that is fine.

            hotkeyid = wx.NewId()
            self.RegisterHotKey(hotkeyid, wx.MOD_CONTROL, ord('H'))

One more thing, is there any page with details information about "keycode" for each key? I mean, how should I know how to refer to the key with '~' if in my keyboard the same key is used for: "~" "`" and ";" ?
Should I use RegisterHotKey 3 times for each one of them?

No. There is a difference between the keycode and the character(s) that may be generated by that key. For the alphanumeric keys the char and key codes have the same value so that is why the ord('H') will work. For the other keys look at the output of the KeyEvent sample in the demo for the KeyDown and KeyUp events when you press the key you are interested in.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!