Skip to content

Commit

Permalink
Handle IndexError if user types too high a digit
Browse files Browse the repository at this point in the history
  • Loading branch information
akkana committed Jun 16, 2014
1 parent ab4c675 commit 0927004
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions MetaPho/gtkpho.py
Expand Up @@ -214,9 +214,11 @@ def next_category(self, howmany) :
self.show_category_by_number(catno)

def show_category_by_number(self, catno) :
'''Show a specific category by number'''
self.categorysel.set_active(catno)
'''Show a specific category by number.
Raises IndexError if catno is out of range.
'''
self.display_tags_for_category(self.categories.keys()[catno])
self.categorysel.set_active(catno)

def highlight_tag(self, tagno, val) :
'''Turn tag number tagno on (if val=True) or off (val=False).'''
Expand Down
6 changes: 5 additions & 1 deletion metapho
Expand Up @@ -288,8 +288,12 @@ class MetaPhoWindow(object):
return True

# Digits: go to a specific tag category
# (ignore digits too large to have a category).
if event.string.isdigit() :
self.tagger.show_category_by_number(int(event.string))
try :
self.tagger.show_category_by_number(int(event.string))
except IndexError :
pass
return True

# + or -: go to next or previous tag
Expand Down

0 comments on commit 0927004

Please sign in to comment.