def realign(self, formWidth):

        rowList = {}
        # Put all of the blocks into rows
        for block in self.contains:
            startRow = block.startPosn[0]
            endRow = block.endPosn[0]
            # Exact match
            if startRow in rowList:
                rowList[startRow].add(block)
                continue
            # look for an overlap
            else:
                overlap = False
                for storedBlock in rowList.values():
                    if (startRow < storedBlock.startRow \
                        and endRow >= storedBlock.startRow) \
                    or (startRow < storedBlock.maxHeight \
                        and endRow >= storedBlock.maxHeight) \
                    or (startRow > storedBlock.startRow) \
                        and (endRow <= storedBlock.maxHeight):
                        storedBlock.add(block)
                        overlap = True
                        break
                if overlap:
                    continue
            # no overlap
            rowList[startRow] = self.RowBlocks(block)
        # Now set up the grow to sizes for each block
        for row in rowList.values():
            # if their is only one row then
            # it just needs to expand to fill the form width
            if row.cnt == 1:
                row.blocks[0].growTo(formWidth)
            # The amount that each block needs to expand to reach the form width
            # needs to be calculated by sharing the shortfall between each block
            # and if any block needs to grow vertically this needs to be added
            # additionally the start position my need adjusting
            else:
                widthShortfall = formWidth - row.maxWidth
                widthShortfallPart = widthShortfall / row.cnt
                colAdjust = 0
                for block in row.blocks:
                    if widthShortfall > 0:
                        widthShortfall -= widthShortfallPart
                        block.slideHorizontally(colAdjust)
                        block.growBy(widthShortfallPart)
                        colAdjust += widthShortfallPart
                    if block.endPosn[0] < row.maxHeight:
                        block.growTo(height = row.maxHeight)
                colAdjust = 0
                for block in row.blocks:
                    if widthShortfall == 0:
                        break
                    block.growBy()
                    widthShortfall -= 1
                    block.slideHorizontally(colAdjust)
                    colAdjust += 1
                rowCnt = len(row.blocks)
                if rowCnt > 1:
                    rowCntList = {}
                    for block in row.blocks:
                        rowCntList[block.startPosn[0]] = True
                    if len(rowCntList) == 1:
                        formWidth = self.growToWidth
        # The growto parameters have been set. Now grow any widgets
        # @todo: add modulo tests for blkCnt to cater for uneven results
        blkCnt = len(self.contains)
        for block in self.contains:
            if block.widgetList == []:
                block.realign(self.growToWidth)
            else:
                self.alignBlock(block, blkCnt)

    # -------------------------------------------------------------------------
Recursive method to ensure all widgets line up
dataset/ETHPy150Open sahana/eden/modules/s3db/survey.py/survey_LayoutBlocks.realign