Skip to content

Commit

Permalink
Menu (#20) fixed shortcuts
Browse files Browse the repository at this point in the history
Fixed bug in shortcuts
  • Loading branch information
Richard Jarvis committed Aug 9, 2016
1 parent 4914cee commit d1d5905
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions appjar.py
Expand Up @@ -3445,6 +3445,7 @@ def addMenuItem(self, title, item, func=None, kind=None, shortcut=None):
if func is not None:
u = self.__makeFunc(func, item, True)
menu.add_command(label=item, command=u, accelerator=shortcut)
shortcut = "<"+shortcut+">"
self.topLevel.bind(shortcut, u)
else:
menu.add_command(label=item, accelerator=shortcut)
Expand Down
10 changes: 5 additions & 5 deletions docs/code/menuTest.py
Expand Up @@ -19,13 +19,13 @@ def showMenus(btn):

app=gui("Menu Tester", "400x400")

app.createMenu("Test 1")
app.createMenu("Test 1", True)
app.createMenu("Test 2")
app.createMenu("Test 3")
app.addMenu("Funky", menuPress)

app.addMenuItem("Test 1", "Option 1", menuPress, shortcut="1")
app.addMenuItem("Test 1", "Option 2", menuPress, shortcut="2")
app.addMenuItem("Test 1", "Option 1", menuPress, shortcut="f")
app.addMenuItem("Test 1", "Option 2", menuPress, shortcut="g")
app.addMenuItem("Test 1", "-")
app.addMenuItem("Test 1", "Option 3", "dogs", kind="rb", shortcut="3")
app.addMenuItem("Test 1", "Option 3", "cats", kind="rb", shortcut="4")
Expand All @@ -40,8 +40,8 @@ def showMenus(btn):
app.addMenuWindow()
app.addMenuPreferences(menuPress)
app.addMenuHelp(menuPress)
app.addMenuItem("help", "Option Help", menuPress, shortcut="b")
app.addMenuItem("window", "Option Help", menuPress, shortcut="b")
app.addMenuItem("help", "Option Help", menuPress, shortcut="h")
app.addMenuItem("window", "Window", menuPress, shortcut="w")

app.addButton("SHOW", showMenus)
app.addTextArea("t1")
Expand Down

0 comments on commit d1d5905

Please sign in to comment.