    def fix(self):
        """
        Fix the layouts and calculate the locations of all the widgets.

        This function should be called once all Layouts have been added to the Frame and all
        widgets added to the Layouts.
        """
        # Remove any focus now before we reset...
        if self._has_focus:
            try:
                self._layouts[self._focus].blur()
            except IndexError:
                pass

        # Do up to 2 passes in case we have a variable height Layout.
        fill_layout = None
        fill_height = y = 0
        for _ in range(2):
            # Pick starting point/height - varies for borders.
            x, y, height, width = self._border_mgr.get_rectangle()
            start_y = y

            # Process each Layout in the Frame - getting required height for
            # each.
            for layout in self._layouts:
                if layout.fill_frame:
                    if fill_layout is None:
                        # First pass - remember it for now.
                        fill_layout = layout
                    elif fill_layout == layout:
                        # Second pass - pass in max height
                        y = layout.fix(x, y, width, fill_height)
                    else:
                        # A second filler - this is a bug in the application.
                        raise Highlander("Too many Layouts filling Frame")
                else:
                    y = layout.fix(x, y, width, height)

            # Can stop now if no fill required.
            if fill_layout is None:
                break

            # We hit a variable height Layout - figure out the available space and reset everything
            # to the new values.
            fill_height = max(1, start_y + height - y)

        # Remember the resulting height of the underlying Layouts.
        self._max_height = y

        # Reset text
        if self._has_focus:
            while self._focus < len(self._layouts):
                try:
                    self._layouts[self._focus].focus(force_first=True)
                    break
                except IndexError:
                    self._focus += 1
            self._clear()
Fix the layouts and calculate the locations of all the widgets.

This function should be called once all Layouts have been added to the Frame and all
widgets added to the Layouts.
asciimatics/widgets/frame.py