我正在使用python 2.7数独检查器并且遇到.get()
的问题,因为它似乎只在最后一帧(条目的底行)上工作,其余只存储空字符串。标记为测试的8行应该输出当前条目的内容。
这是代码:
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()