trying to impleament a checkWin function that checks all possible wins for a player, but I'm notreally sure how to do it.

from connect4cell2 import Connect4Cells
from Tkinter import *

class Connect4Frame(object):
    COLORS = ["White", "Red", "Yellow"]
    def __init__(self,rows = 6, columns = 7):
        self.cells = Connect4Cells(rows, columns, 3)
        self.rows = rows
        self.columns = columns
            self.atRow = 0
            self.atColumn = 0
            self.root = Tk()
            self.root.title("Connect 4")
            self.player = 1

            self.buttons = []
            for i in range(self.rows):
                for j in range(self.columns):
                    btn = Button(self.root,command=lambda x=i,y=j:self.clicked(x,y),\


        def clicked(self, rowIndex, columnIndex):

            self.atRow = rowIndex
            self.atColumn = columnIndex
            result = self.cells.clickAt(self.atColumn,self.player)
            if result:
                self.player = 3 - self.player


    def colorButtons(self):
        for i in range(self.rows):
            for j in range(self.columns):

    def mainloop(self):

w = Connect4Frame()

the coding i imported into my frame

class Connect4Cells(object):
    def __init__(self, rows = 7, columns=6, numcolors = 3):
        self._rowCounts = rows
        self._numColors = numcolors
        self._columnCounts = columns
        self._cells = []
        for i in range(rows):
            for j in range(columns):

    def checkRow(self, rowIndex):
        for j in range(self.columns):
            if self._cells[rowIndex][j] == 0:
                return True
        return False

    def checkColumn(self, columnIndex):
        for i in range(self.rows):
            if self._cells[i][columnIndex] == 0:
                return True
        return False

    def getFirstEmptyCell(self, columnIndex):
        k = self._rowCounts - 1
        while self._cells[k][columnIndex] != 0:
            k -= 1
        return k

    def clickAt(self, columnIndex, player):
        row = self.getFirstEmptyCell(columnIndex)
        if row < 0:
            return False
        self._cells[row][columnIndex] = player
        return True

    def getCellNumber(self,rowIndex,columnIndex):
        return self._cells[rowIndex][columnIndex]

    def checkWin(self, rowIndex,columnIndex,player):
        for i in range(self.columns):
            for j in range(self.rows):
                if self._cells[i][j] == self._cells[i+j] == self._cells[i+3][j] == self._cells[i][j+3] == player:
                    if player == 1:
                        print "player 1 wins"
                        print "player 2 wins"

from connect4cell2 import Connect4Cells
make sure the file you are importing is saved as

self.cells = Connect4Cells(rows, columns, 3)
self.cells can now use any of the instances methods like
row_flag = self.cells.checkRow(rowIndex)
you have to supply the rowIndex value

You could also have a list of win squares instead of checking for rows, diagonals, and columns separately. The following is pseudo-code:

def check_row(self, row):
    for column in row
        ## not occupied or not all the same
        if column == 0 or column != control:
            return False
    return True

def checkWin(self):
    ## check rows
    for j in range(self.rows)
        result = self.check_row(self.rows[j])  ## or just use for row in self.rows
        if result:
            print "Winner is player", self.player
            return result, self.player

    ## check_column would be the same as check_row, i.e. you could use
    ## the same function if you sent it a list of all rows[0] instead
    ## for example, and the same for diagonals
    result = check_column()   
    result = check_diagonal()