The window doesn't update before the messagebox however the update function (printBoard()) is called before the messagebox.
I have a problem with a tic tac to script against a bot, when there is a winner or a tie game the program shows that to the user using a messagebox, but in my code I call the function printBoard(board)
and this updates the window for the game. And after that I call the messagebox.showinfo
but as soon as the messagebox shows up the board has not been updated.
(the problem is in the function checkWinner(board)
)
def printBoard(board):
bbuttons = [[0,0,0],[0,0,0],[0,0,0]]
for y in range(0,3):
for x in range(0,3):
bbuttons[y][x] = Button(text=board[y][x], font= ('Arial',50))
bbuttons[y][x].grid(row=y, column=x)
bbuttons[y][x].config(height=1, width=3)
return
if checkWinner(board) == 'X':
o = printBoard(board)
messagebox.showinfo("WON!", "YOU WON!")
board = [[' ',' ',' '],[' ',' ',' '],[' ',' ',' ']]
root.destroy()
start()
Output:
[['X', 'X', 'O'], ['O', 'X', 'X'], ['X', 'O', 'O']]
I want the board to have been updated so that you can see for example three x's in a row. (now it doesn't it just shows the messagebox when you click the last tile)
UPDATE: Now I'm home and ran the script on my Windows Pc and it works without the problem. It seems to be Mac specifically (I tested it on another mac also).