+ self.refresh_list()
+ super(ListView, self).refresh()
+
+ def refresh_list(self):
+ """ Reload the list items. Calls items() again. """
+ # Remember which item was selected
+ selected = self.selected_item()
+ # Refresh the list
+ self.items_cache = self.items()
+ try:
+ # Try to find the selected item in the new list (based on
+ # the display text).
+ selected_index = self.items_cache.index(selected)
+ except ValueError:
+ # If the selected item is no longer present, just keep the
+ # index the same (but be careful not to fall off the end).
+ selected_index = self.clip_index(self.selected_index())
+ # Update the items in the view
+ self.view.set_list(self.items_cache, selected_index)
+
+ def run(self):
+ self.index_changed()
+ super(ListView, self).run()
+
+ 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):
+ """
+ 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 []