Hi

I am new to python and am learning how to use tkinter. I am creating a game and need to create callbacks for the buttons so the game has a cell location when a player clicks on the corresponding button. I am unsure on how to do this, hope someone can help. So far I have created the following:

btn_list = [
    '',  '',  '',  '',  '',
    '',  '',  '',  '',  '',
    '',  '',  '',  '',  '',
    '',  '',  '',  '',  '',
    '',  '',  '',  '',  '']

    r = 1
    c = 0
    for b in list:
        rel = 'sunken'
        cmd = lambda x=b: click()
        Button(root,width=4,relief=rel,command=cmd).grid(row=r,column=c)
       
        c += 1
        if c > 4:
            c = 0
            r += 1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.