[wxPython] Shortcuts for buttons

I looked at the demo.py and at the wiki, but I can't find a solution
to make shortcuts for buttons. In menu items you can do it with
"&foo", but how do I get something like this for buttons? I would like
an application where I can control everything without a mouse.

One solution is to use an eventhandler, but how do I underline
characters in buttons, so that the user knows which shortcuts are
available?

thomas

···

--
Thomas Guettler <guettli@thomas-guettler.de>
http://www.thomas-guettler.de

I looked at the demo.py and at the wiki, but I can't find a solution
to make shortcuts for buttons. In menu items you can do it with
"&foo", but how do I get something like this for buttons? I would like
an application where I can control everything without a mouse.

One solution is to use an eventhandler, but how do I underline
characters in buttons, so that the user knows which shortcuts are
available?

On wxMSW you can still use the & in button's label and it draws the
underline and also takes care of capturing the Alt-key and turning it into a
EVT_BUTTON. I don't think that is supported with wxGTK, but you can at
least use a wxAcceleratorTable to define the keys that should be turned into
events.

···

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

Sad to hear that it is not supported on wxGTK. But it should be easy
to program this myself.

Two questions:

1. Why does EVT_CHAR don't give me events? EVT_SIZE does work

class MyFrame(wxFrame):
  def __init__(self):
    wxFrame.__init__(self, NULL, ID_NULL, "SimpleImageViewer")
    EVT_CHAR(self, self.onChar)
    EVT_SIZE(self, self.onSize)
  
2. Who can I underline a character in a button?

thomas

···

On Tue, Apr 23, 2002 at 03:02:13PM -0700, Robin Dunn wrote:

> I looked at the demo.py and at the wiki, but I can't find a solution
> to make shortcuts for buttons. In menu items you can do it with
> "&foo", but how do I get something like this for buttons? I would like
> an application where I can control everything without a mouse.
>
> One solution is to use an eventhandler, but how do I underline
> characters in buttons, so that the user knows which shortcuts are
> available?

On wxMSW you can still use the & in button's label and it draws the
underline and also takes care of capturing the Alt-key and turning it into a
EVT_BUTTON. I don't think that is supported with wxGTK, but you can at
least use a wxAcceleratorTable to define the keys that should be turned into
events.

--
Thomas Guettler <guettli@thomas-guettler.de>
http://www.thomas-guettler.de

Two questions:

1. Why does EVT_CHAR don't give me events? EVT_SIZE does work

class MyFrame(wxFrame):
def __init__(self):
wxFrame.__init__(self, NULL, ID_NULL, "SimpleImageViewer")
EVT_CHAR(self, self.onChar)
EVT_SIZE(self, self.onSize)

EVT_CHAR events go only to the window that has the keyboard focus, and do
not travel up the parental heirarchy.

2. Who can I underline a character in a button?

If the native widget doesn't handle by putting the '&' in the label then
you'll have to either draw it yourself in an idle handler, or use custom
buttons where you draw everything.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!
\