Over a million developers have joined DZone.

The New ShortcutEditor for wxPython

DZone's Guide to

The New ShortcutEditor for wxPython

· Web Dev Zone
Free Resource

Discover how to focus on operators for Reactive Programming and how they are essential to react to data in your application.  Brought to you in partnership with Wakanda

I meant to write up a post on this within a week of reading about it, but then things got busy and I forgot. Anyway, there’s a new widget in the wxPython toolkit called the ShortcutEditor. You can read about it on the wxPython mailing list. You’ll probably have to update the agw lib folder on your local drive unless you run from SVN a lot. It may be included in the latest Phoenix builds too, but I’m not sure. If you want to check it out, do the following on the command line (assuming you have svn installed)

svn checkout http://svn.wxwidgets.org/svn/wx/wxPython/3rdParty/AGW/agw/

 That will create an “agw” folder in whatever your current directory is. You’ll want to copy that over the top of the one that’s in your wxPython installation. On my machine, it was in the following location: C:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib There’s a simple demo application included in the source code. I’m reproducing it here so you can see try running it too:

import wx
import wx.lib.agw.shortcuteditor as SE

class MyFrame(wx.Frame):

def __init__(self, parent):

wx.Frame.__init__(self, parent, -1, "ShortcutEditor Demo")

bar = wx.MenuBar()
menu = wx.Menu()

menu.Append(101, "&Mercury", "This the text in the Statusbar")
menu.Append(102, "&Venus", "")
menu.Append(103, "&Earth", "You may select Earth too")
menu.Append(104, "&Close", "Close this frame")

bar.Append(menu, 'File')

dlg = SE.ShortcutEditor(self)

if dlg.ShowModal() == wx.ID_OK:
# Changes accepted, send back the new shortcuts to the TLW wx.MenuBar


# our normal wxApp-derived class, as usual

app = wx.App(0)

frame = MyFrame(None)


If you run the code above, you should see something like this on your screen:

Then you can start changing short cut keys. I thought it was really cool. According to the file’s internal documentation, it can change menu shortcut keys and AcceleratorTables. You should give it a try sometime. I think this will be a pretty helpful utility to add to my own scripts.

Learn how divergent branches can appear in your repository and how to better understand why they are called “branches".  Brought to you in partnership with Wakanda


Published at DZone with permission of Mike Driscoll, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}