Making sure the input in the entry is a number between 1-9 and is only a digit, else remove the input and give a error message. It would be nice to define a function that can validate the input. also any suggestion on changing the text colour on DISABLED state entry.
board=[[0]*9]*9
def box3x3():
if test_level[x][y]!=0:
var= StringVar(board_frame,value=str(test_level[x][y]))
board[y][x]=Entry(board_frame,state=DISABLED,textvariable=var,justify=CENTER,bd=5,bg="light grey",width=3,font=("Arial Black",24)).grid(row=x,column=y)
else:
board[y][x]=Entry(board_frame,justify=CENTER,fg="maroon",bd=5,bg="light grey",width=3,font=("Arial Black",24)).grid(row=x,column=y)
def box3x3_2():
if test_level[x][y]!=0:
var= StringVar(board_frame,value=str(test_level[x][y]))
board[y][x]=Entry(board_frame,state=DISABLED,textvariable=var,justify=CENTER,bd=1,bg="light grey",width=3,font=("Arial Black",24)).grid(row=x,column=y)
else:
board[y][x]=Entry(board_frame,justify=CENTER,fg="maroon",bd=1,bg="light grey",width=3,font=("Arial Black",24)).grid(row=x,column=y)
test_level = [[5,1,7,6,0,0,0,3,4],
[2,8,9,0,0,4,0,0,0],
[3,4,6,2,0,5,0,9,0],
[6,0,2,0,0,0,0,1,0],
[0,3,8,0,0,6,0,4,7],
[0,0,0,0,0,0,0,0,0],
[0,9,0,0,0,0,0,7,8],
[7,0,3,4,0,0,5,6,0],
[0,0,0,0,0,0,0,0,0]]
#gui of the board
from tkinter import *
root=Tk()
root.title("SUDOKU")
board_frame=Frame(root).grid(row=0,column=0)
for y in range(0,3):
for x in range(0,3):
box3x3()
for y in range(3,6):
for x in range(0,3):
box3x3_2()
for y in range(6,9):
for x in range(0,3):
box3x3()
#2nd row
for x in range(3,6):
for y in range(0,3):
box3x3_2()
for x in range(3,6):
for y in range(3,6):
box3x3()
for x in range(3,6):
for y in range(6,9):
box3x3_2()
#last row
for x in range(6,9):
for y in range(0,3):
box3x3()
for x in range(6,9):
for y in range(3,6):
box3x3_2()
for x in range(6,9):
for y in range(6,9):
box3x3()
root.mainloop()