From 0be176c06676dcaf537a4fbb262a8c655c74cff9 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Sun, 30 Aug 2009 09:30:54 +0200 Subject: [PATCH] Define (a dummy) get_menu_entries in View. Also, make KeyBindingView call the next get_menu_entries method, allowing for other classes to override the method as well. --- src/gui/gui.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/gui/gui.py b/src/gui/gui.py index 2661286..33f8973 100644 --- a/src/gui/gui.py +++ b/src/gui/gui.py @@ -146,6 +146,15 @@ class View(object): """ super(View, self).refresh() + def get_menu_entries(self): + """ Returns a list of menu entries to display. Will be + automatically updated on each refresh. + + Each menu entry is a tuple of a title for the entry and a + function to call when the entry is selected. + """ + return [] + class ListView(View): def __init__(self): super(ListView, self).__init__() @@ -188,7 +197,6 @@ class ListView(View): def selected_index(self): return self.view.current() - class WidgetBasedListView(ListView): def __init__(self): self.widgets = self.generate_widgets() @@ -248,7 +256,8 @@ class KeyBindingView(View): description=' '+description menu_entries.append((description,function)) menu_entries.append((u'Exit', self.exit)) - return menu_entries + return menu_entries + super(KeyBindingView, self).get_menu_entries() + def set_bindings_for_selection(self,selected_index): self.remove_all_key_bindings() -- 2.30.2