Meine Frage ist, wie kann ich meine Entrys die alle in einem Grid liegen neu zeichnen lassen
(
Code: Alles auswählen
def __init__(self):
# object of tkinter frame... creates a new window
self.window = Tk()
# set title of window
self.preGrid()
## for i in range(9):
## self.cells.append([]) # leeres array fuer zweidimensionales
## for j in range(9):
## val = self.m.getAttribut(i,j)
## if (val <= 0):
## val = ""
## else:
## val = str(val)
## self.cells[i].append(StringVar(None, val))
self.window.title("Sudoku")
self.frame = Frame(self.window) # Hold entries
self.frame.pack()
self.m.prepareField()
# 00 01 02 | 03 04 05 | 06 07 08
# 2. 10 11 12 | 13 14 15 | 16 17 18
# 3. 20 21 22 | 23 24 25 | 26 27 28
# 4. 30 31 32 | 33 34 35 | 36 37 38
# 5. 40 41 42 | 43 44 45 | 46 47 48
# 6. 50 51 52 | 53 54 55 | 56 57 58
# 7. 60 61 62 | 63 64 65 | 66 67 68
# 8. 70 71 72 | 73 74 75 | 76 77 78
# 9. 80 81 82 | 83 84 85 | 86 87 88
for i in range(9):
for j in range(9):
if(i <=2):
if( j >= 3 and j <= 5):
Entry(self.frame, width = 2, justify = RIGHT,
textvariable = self.cells[i][j],bg="grey").grid(
row = i, column = j)
else:
Entry(self.frame, width = 2, justify = RIGHT,
textvariable = self.cells[i][j]).grid(
row = i, column = j)
elif( i >=3 and i <=5):
if(j <=2 or j >=6):
Entry(self.frame, width = 2, justify = RIGHT,
textvariable = self.cells[i][j],bg="grey").grid(
row = i, column = j)
else:
Entry(self.frame, width = 2, justify = RIGHT,
textvariable = self.cells[i][j]).grid(
row = i, column = j)
elif(i > 5):
if(j >=3 and j <=5):
Entry(self.frame, width = 2, justify = RIGHT,
textvariable = self.cells[i][j], bg ="grey").grid(
row = i, column = j)
else:
Entry(self.frame, width = 2, justify = RIGHT,
textvariable = self.cells[i][j]).grid(
row = i, column = j)
Button(self.window, text = "validate").pack(side = LEFT)
Button(self.window, text = "delete").pack(side = LEFT)
Button(self.window, text = "new Game", command = self.printField).pack( side = LEFT)
# create an event loop
self.window.mainloop()
def printField(self):
self.preGrid()
self.frame.update()
pass