DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. The New ShortcutEditor for wxPython

The New ShortcutEditor for wxPython

Mike Driscoll user avatar by
Mike Driscoll
·
Jun. 26, 12 · Interview
Like (0)
Save
Tweet
Share
2.49K Views

Join the DZone community and get the full member experience.

Join For Free

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.AppendSeparator()
menu.Append(104, "&Close", "Close this frame")

bar.Append(menu, 'File')
self.SetMenuBar(bar)

dlg = SE.ShortcutEditor(self)
dlg.FromMenuBar(self)

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

dlg.Destroy()

# our normal wxApp-derived class, as usual

app = wx.App(0)

frame = MyFrame(None)
app.SetTopWindow(frame)
frame.Show()

app.MainLoop()

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.

application Documentation Directory Command (computing) Machine Data Types

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

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Front-End Troubleshooting Using OpenTelemetry
  • Testing Repository Adapters With Hexagonal Architecture
  • DevOps vs Agile: Which Approach Will Win the Battle for Efficiency?
  • Understanding and Solving the AWS Lambda Cold Start Problem

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: