'Helper to create the grid of GUI cells.
The edge (x==0 or y==0) is filled with labels; the rest is real cells.'

def makegrid(self, rows, columns):

    self.rows = rows
    self.columns = columns
    self.gridcells = {}
    cell = Tk.Label(self.cellgrid, relief='raised')
    cell.grid_configure(column=0, row=0, sticky='NSWE')
    cell.bind('<ButtonPress-1>', self.selectall)
    for x in range(1, (columns + 1)):
        self.cellgrid.grid_columnconfigure(x, minsize=64)
        cell = Tk.Label(self.cellgrid, text=colnum2name(x), relief='raised')
        cell.grid_configure(column=x, row=0, sticky='WE')
        self.gridcells[(x, 0)] = cell
        cell.__x = x
        cell.__y = 0
        cell.bind('<ButtonPress-1>', self.selectcolumn)
        cell.bind('<B1-Motion>', self.extendcolumn)
        cell.bind('<ButtonRelease-1>', self.extendcolumn)
        cell.bind('<Shift-Button-1>', self.extendcolumn)
    for y in range(1, (rows + 1)):
        cell = Tk.Label(self.cellgrid, text=str(y), relief='raised')
        cell.grid_configure(column=0, row=y, sticky='WE')
        self.gridcells[(0, y)] = cell
        cell.__x = 0
        cell.__y = y
        cell.bind('<ButtonPress-1>', self.selectrow)
        cell.bind('<B1-Motion>', self.extendrow)
        cell.bind('<ButtonRelease-1>', self.extendrow)
        cell.bind('<Shift-Button-1>', self.extendrow)
    for x in range(1, (columns + 1)):
        for y in range(1, (rows + 1)):
            cell = Tk.Label(self.cellgrid, relief='sunken', bg='white', fg='black')
            cell.grid_configure(column=x, row=y, sticky='NSWE')
            self.gridcells[(x, y)] = cell
            cell.__x = x
            cell.__y = y
            cell.bind('<ButtonPress-1>', self.press)
            cell.bind('<B1-Motion>', self.motion)
            cell.bind('<ButtonRelease-1>', self.release)
            cell.bind('<Shift-Button-1>', self.release)
