    def focus(self, force_first=False, force_last=False, force_column=None,
              force_widget=None):
        """
        Call this to give this Layout the input focus.

        :param force_first: Optional parameter to force focus to first widget.
        :param force_last: Optional parameter to force focus to last widget.
        :param force_column: Optional parameter to mandate the new column index.
        :param force_widget: Optional parameter to mandate the new widget index.

        The force_column and force_widget parameters must both be set together or they will
        otherwise be ignored.

        :raises IndexError: if a force option specifies a bad column or widget, or if the whole
            Layout is readonly.
        """
        logger.debug("Focus: %s", self)
        had_focus = self._has_focus
        col, wid = self._live_col, self._live_widget
        self._has_focus = True
        if force_widget is not None and force_column is not None:
            self._live_col = force_column
            self._live_widget = force_widget
        elif force_first:
            self._live_col = 0
            self._live_widget = -1
            self._find_next_widget(1)
        elif force_last:
            self._live_col = len(self._columns) - 1
            self._live_widget = len(self._columns[self._live_col])
            self._find_next_widget(-1)
        if self._live_widget == -1:
            raise IndexError("No live widgets")
        if (col, wid) != (self._live_col, self._live_widget) or not had_focus:
            self._columns[self._live_col][self._live_widget].focus()
Call this to give this Layout the input focus.

:param force_first: Optional parameter to force focus to first widget.
:param force_last: Optional parameter to force focus to last widget.
:param force_column: Optional parameter to mandate the new column index.
:param force_widget: Optional parameter to mandate the new widget index.

The force_column and force_widget parameters must both be set together or they will
otherwise be ignored.

:raises IndexError: if a force option specifies a bad column or widget, or if the whole
Layout is readonly.
asciimatics/widgets/layout.py