1

I'm working on a python 2.7 sudoku checker and am having trouble with the .get(), as it seems it is only working on the last frame (bottom row of entries), the rest just stores empty strings. there's 8 lines marked as test that should output what is currently on the entries. Here is the code:

from Tkinter import *

def armar(x):
        global sudoku
        global matriz
        for i in range(9):
                for j in range(9):
                        if matriz[i][j].get()!="":
                           sudoku[i][j]=matriz[i][j].get()
                           sudoku[i][j]=int(sudoku[i][j])
                        else:
                           sudoku[i][j]=0
        #test---------------------------------
        for fila in sudoku:
                for numero in fila:
                        print numero,
                print
        for fila in matriz:
                for numero in fila:
                        print numero.get(),
                print
        #---------------------------------------
matriz = [[0]*9]*9
sudoku = [[0]*9]*9
marco = [0]*9

#-------------Window---------------
ventana = Tk()

#Marcos
for i in range(9):
        marco[i]=Frame(ventana)
        marco[i].pack()

#Cuadricula
for i in range(9):
        for j in range(9):
                matriz[i][j]=Entry(marco[i], width=3)
                matriz[i][j].pack(side=LEFT)
                matriz[i][j].bind("<Return>", armar)

ventana.mainloop()
Cœur
  • 37,241
  • 25
  • 195
  • 267

0 Answers0