This patch provides get_focus for container.py::Frame and container.py::GridFlow, the only two container-like widgets (I could see) that provide multiple areas of focus, methods for setting focus, but no method for determining the current focus.
It's a pretty simple patch, but it would appear to be useful (based on a conversation I participated in on IRC) and provide consistency. Hopefully this is the right method for formatting and submitting patches; I have not used mercurial that much. -Jon
# HG changeset patch # User Jon McManus <[email protected]> # Date 1292737598 -36000 # Node ID ab549a07ed8fa001fafba9e41ee7ca7907d1122c # Parent 7294418abe37eacdb38cc53f17b1959db5bde371 Provide get_focus functions for Frame, GridFlow. Of the container classes defined in container.py, only these two had multiple focus areas and the ability to specify which one should be focussed upon, but no method for determining focus. diff -r 7294418abe37 -r ab549a07ed8f urwid/container.py --- a/urwid/container.py Sat Aug 21 08:33:44 2010 -0400 +++ b/urwid/container.py Sun Dec 19 15:46:38 2010 +1000 @@ -132,6 +132,10 @@ self._invalidate() + def get_focus (self): + """Return the widget in focus.""" + return self.focus_cell + def get_display_widget(self, size): """ Arrange the cells into columns (and possibly a pile) for @@ -497,6 +501,13 @@ self.focus_part = part self._invalidate() + def get_focus (self): + """Return the part of the frame that is in focus. + + Will be one of 'header', 'footer' or 'body'. + """ + return self.focus_part + def frame_top_bottom(self, size, focus): """Calculate the number of rows for the header and footer.
_______________________________________________ Urwid mailing list [email protected] http://lists.excess.org/mailman/listinfo/urwid
