-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
55 lines (37 loc) · 1.07 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import src.gameoflife as game
import tkinter as tk
game_map = game.Map(60, 40)
window = tk.Tk()
canvas = tk.Canvas(window, bg='white')
renderer = game.CanvasRenderer(canvas,game_map)
renderer.cell_size = 10
renderer.render()
autorun = False
def stop_action():
global autorun
autorun = False
def start_action():
global autorun
autorun = True
def step_action():
game_map.step()
renderer.render()
def clear_action():
stop_action()
game_map.clear()
renderer.render()
def autorun_action():
if autorun:
step_action()
window.after(1,autorun_action)
button_step = tk.Button(window, text='step', command=step_action)
button_start = tk.Button(window, text='start', command=start_action)
button_stop = tk.Button(window, text='stop', command=stop_action)
button_clear = tk.Button(window, text='clear', command=clear_action)
button_step.grid(row=0, column=2)
button_start.grid(row=0, column=3)
button_stop.grid(row=0, column=4)
button_clear.grid(row=0, column=5)
canvas.grid(row=1, column=0, columnspan=6)
autorun_action()
window.mainloop()