def fillCells(self, value):
        """Fill cells with a given value.

        value       --  string value to place into cells

        This uses the member variable _selectedCells, a list of (i,j) tuples for
        the selected cells.
        """
        for (i,j) in self._selectedCells:
            if not self.gridAtoms.IsReadOnly(i,j):
                # Get the last valid text from the cell. For the cell that triggered
                # this method, that is the _focusedText, for other cells it is the
                # value returned by GetCellValue
                oldvalue = self._focusedText
                if oldvalue is None:
                    oldvalue = self.gridAtoms.GetCellValue(i,j)
                self._focusedText = None
                newvalue = self.applyCellChange(i,j, value)
                #print i, j, value, oldvalue, newvalue
                if newvalue is None:
                    # Get out of here. If the value is invalid, it won't be valid
                    # for any cells.
                    newvalue = oldvalue
                    self.gridAtoms.SetCellValue(i,j,str(newvalue))
                    break
                else:
                    self.gridAtoms.SetCellValue(i,j,str(newvalue))

        gridutils.quickResizeColumns(self.gridAtoms, self._selectedCells)
        return
def pasteIntoCells(panel):
    """Paste clipboard contents into cells.

    canPasteIntoCells must be called before this method in order to format
    clipboard text for pasting.
    """
    # Double check the clipcells
    if len(clipcells) == 0: return
    if len(clipcells[0]) == 0: return

    grid = panel.gridAtoms
    individuals = grid.GetSelectedCells()
    topleft = grid.GetSelectionBlockTopLeft()
    if len(individuals) > 0:
        tl = individuals[0]
    elif len(topleft) > 0:
        tl = topleft[0]
    else:
        return
    rtl = tl[0]
    ctl = tl[1]

    nrows = grid.GetNumberRows()
    ncols = grid.GetNumberCols()

    rbr = min(nrows, rtl + len(clipcells)) - 1
    cbr = min(ncols, ctl + len(clipcells[0])) - 1

    selections = []
    for row in range(rtl, rbr + 1):
        for col in range(ctl, cbr + 1):
            if not grid.IsReadOnly(row, col):
                oldvalue = panel.gridAtoms.GetCellValue(row, col)
                newvalue = panel.applyCellChange(
                    row, col, clipcells[row - rtl][col - ctl])
                if newvalue is None: newvalue = oldvalue
                panel.gridAtoms.SetCellValue(row, col, str(newvalue))
                selections.append((row, col))

    gridutils.quickResizeColumns(panel.gridAtoms, selections)

    # Clear the grid and select the inserted entries
    grid.ClearSelection()
    #panel.refresh()
    for row in range(rtl, rbr + 1):
        for col in range(ctl, cbr + 1):
            if not grid.IsReadOnly(row, col):
                grid.SelectBlock(row, col, row, col, True)
    return