From: Matthijs Kooijman Date: Tue, 3 Nov 2009 14:53:54 +0000 (+0100) Subject: Add ListView.selected_item helper. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=44d266884b779d4273a224903dddf8f4def9e0c8;hp=18b26fe9afc8734f3adb22cfa6b0ed6b68a8970e;p=matthijs%2Fupstream%2Fmobilegtd.git Add ListView.selected_item helper. --- diff --git a/src/gui/gui.py b/src/gui/gui.py index f7ee31e..3d4e6fb 100644 --- a/src/gui/gui.py +++ b/src/gui/gui.py @@ -251,6 +251,13 @@ class ListView(View): """ Changes the currently selected item to index. """ self.view.set_list(self.items(),index % len(self.items())) + def selected_item(self): + """ Returns the (title of the) currently selected list item. """ + if not self.items_cache: + return None # No items, so none is selected. + return self.items_cache[self.selected_index()] + + def selected_index(self): """ Returns the currently selected index. """ if not self.current_index is None: