From 5fcc75ca804e33c270b0d3047cfc47926fe4a6fe Mon Sep 17 00:00:00 2001 From: Pavel Marychev Date: Tue, 3 Aug 2021 22:55:14 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB=20vi?= =?UTF-8?q?ew?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ch11/view.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 ch11/view.py diff --git a/ch11/view.py b/ch11/view.py new file mode 100644 index 0000000..380a2d4 --- /dev/null +++ b/ch11/view.py @@ -0,0 +1,41 @@ +from tkinter import * +import model + +cell_size = 5 + + +def setup(): + global root, grid_view, cell_size, start_button, clear_button, choice + + root = Tk() + root.title('The Game of Life') + + grid_view = Canvas(root, width=model.width * cell_size, + height=model.height * cell_size, + borderwidth=0, + highlightthickness=0, + bg='white') + + start_button = Button(root, text='Start', width=12) + clear_button = Button(root, text='Clear', width=12) + + choice = StringVar(root) + choice.set('Choose a Pattern') + option = OptionMenu(root, choice, 'Choose a Pattern', 'glider', + 'glider gun', 'random') + option.config(width=20) + + # grid_view.pack() + # start_button.pack() + # option.pack() + # clear_button.pack() + + grid_view.grid(row=0, columnspan=3, padx=20, pady=20) + start_button.grid(row=1, column=0, sticky=W, padx=20, pady=20) + option.grid(row=1, column=1, padx=20) + clear_button.grid(row=1, column=2, sticky=E, padx=20, pady=20) + + +if __name__ == '__main__': + setup() + mainloop()