From 44d266884b779d4273a224903dddf8f4def9e0c8 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 3 Nov 2009 15:53:54 +0100 Subject: [PATCH 1/1] Add ListView.selected_item helper. --- src/gui/gui.py | 7 +++++++ 1 file changed, 7 insertions(+) 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: -- 2.30.2