# HG changeset patch # User Björn Ricks # Date 1365185660 -7200 # Node ID f958ce12ba5aa600a8d67f24d18cbbb176f2a0ab # Parent c8f85809607b15a7ea9e3086671d17567d1d6a59 Implement an own ListWalker class Allow to handle focus changed via a callback method in the widget class. diff -r c8f85809607b -r f958ce12ba5a getan/walker.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/getan/walker.py Fri Apr 05 20:14:20 2013 +0200 @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# +# (c) 2013 by Björn Ricks +# +# This is Free Software licensed under the terms of GPLv3 or later. +# For details see LICENSE coming with the source of 'getan'. +# +import logging + +import urwid + + +logger = logging.getLogger(__name__) + +class ListWalker(urwid.SimpleListWalker): + + def __init__(self, content, widget=None): + logger.info("Init ListWalker") + super(ListWalker, self).__init__(content) + self.widget = widget + self.position = None + + def set_focus(self, position): + super(ListWalker, self).set_focus(position) + if self.widget and self.position != position: + self.position = position + self.widget.content_focus_changed() +