+ 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__()
+ self.set_view(appuifw.Listbox(self.items(),self.entry_selected))
+ self.view.bind(EKeyUpArrow,lambda: self.arrow_key_pressed(-1))
+ self.view.bind(EKeyDownArrow,lambda: self.arrow_key_pressed(1))
+
+ def arrow_key_pressed(self, dir):
+ """
+ This function is called when an arrow key is pressed. Since we
+ don't get any "current list index has changed" events, we'll
+ have to create these ourselves this way.
+
+ Since the current index is only updated after the key event,
+ we'll have to adjust the index with the direction of the
+ keypress (-1 for up, +1 for down).
+ """
+ new_index = (self.selected_index() + dir) % len(self.items())
+ self.index_changed(new_index)
+
+ def entry_selected(self):
+ """
+ This function is called when the user selects an an entry (e.g.,
+ navigates to it and push the ok button).
+ """
+ pass
+
+ def index_changed(self,new_index):
+ """
+ This function is called when the index changes. The given index
+ is the new index (don't use self.selected_index() here, since it
+ won't be correct yet!).
+ """
+ pass
+
+ def items(self):
+ """ This function should return the list of items to display.
+ See appuifw.ListBox for valid elements for this list. """
+ return []
+