Re: Re: GenButton and acceleratorTable

Nicolas Pinault <[email protected]> Fri, 21 Dec 2018 21:47:03 +0100
Newsgroups gmane.comp.python.wxpython.devel
Message-ID <[email protected]>
Le 20/12/2018 à 20:28, Robin Dunn a écrit :
> On Thursday, December 20, 2018 at 9:06:39 AM UTC-8, Nicolas Pinault 
> wrote:
>
>     Le 19/12/2018 à 01:06, Robin Dunn a écrit :
>     There is no menu in my app.
>     Are you saying I have to use a menu in my app ?
>
>
>
> No, but accelerator tables are meant to be used in conjunction with 
> menus or toolbars, so it will generate EVT_MENU when the key is 
> pressed. You don't need to have a menu to bind handers for EVT_MENU.
>
Ok. So trying again ;)
Is the following right ?
         accelerator_table = wx.AcceleratorTable([(wx.ACCEL_NORMAL, 
wx.WXK_LEFT,  0),
(wx.ACCEL_NORMAL, wx.WXK_RIGHT, 1),
(wx.ACCEL_SHIFT,  wx.WXK_LEFT,  2),
(wx.ACCEL_SHIFT,  wx.WXK_RIGHT, 3),
(wx.ACCEL_NORMAL, wx.WXK_SPACE, 4)])
         self.SetAcceleratorTable(accelerator_table)
         self.Bind(wx.EVT_MENU, self.accel)

     def accel(self, event):
         print(event.Id)

>
>
>     What I want to achieve is to trig actions either by clicking a
>     button, or by hitting a key. I thought accelerator table is able
>     to achieve this.
>
>
>
> Do you really need Button or GenButton, or would normal toolbar tools 
> work for you? They can have an icon plus a label if you need it.
Toolbar tools are ok. I started with buttons since this is quicker to 
set up. No picture files to manage.

Nicolas
>
> --
> Robin
>
>
> -- 
> You received this message because you are subscribed to the Google 
> Groups "wxPython-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected] 
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.