Skip to content

Commit

Permalink
extract show
Browse files Browse the repository at this point in the history
  • Loading branch information
nitsanavni committed Nov 10, 2023
1 parent 80859a2 commit 4a2e6bc
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tests/test_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def __init__(self, game_of_life,width=10,height=10):
self.cell_size = 10
self.cells = {}
self.create_widgets()


def show(self):
self.root.mainloop()

def create_widgets(self):
Expand All @@ -39,17 +40,15 @@ def update_cells(self):
for x in range(self.width):
for y in range(self.height):
if self.game.is_alive(x, y):
self.cells[(x, y)].config(bg='black')
self.cells[(x, y)].config(bg='blue')
else:
self.cells[(x, y)].config(bg='white')
self.cells[(x, y)].config(bg='grey')

def test_tkinter_gui():
game = GameOfLife()
create_glider_at(game, 0, 0)
gui = TkinterGui(game)
gui.root.update() # Update the GUI frame to show latest cell configurations
gui.root.after(2000, lambda: gui.root.destroy()) # Keep the window open for 2 seconds and then close it
gui.root.mainloop() # Start the GUI event loop
gui.show()

def create_glider_at(game,x,y):
game.set_alive(x+0,y+1)
Expand Down

0 comments on commit 4a2e6bc

Please sign in to comment.