#Code is originally written by Professor Richard Pattis' of #of University Of Califorina, Irvine. I made some modifications. #The view module sets up what is seen on the GUI from tkinter import Tk,Frame,TOP,LEFT,BOTTOM,RAISED,BOTH # import controller to call/create widgets and position them in the view import controller # Construct a simple root window root = Tk() root.title("Simulation") root.protocol("WM_DELETE_WINDOW",quit) root.resizable(0, 0) #this prevents you from resizing the window frame = Frame(root) # Place buttons simply at the top frame.pack(side=TOP) controller.reset_button (frame,text="Reset") .pack(side=LEFT) controller.pause_button (frame,text="Pause") .pack(side=LEFT) controller.progress(frame,text="Score: 0",width=25,relief=RAISED).pack(side=LEFT) # Place canvas in the space below controller.simulation_canvas(root,width=500,height=300,bg="black").pack(side=BOTTOM,expand=True,fill=BOTH)
from tkinter import Tk, Frame, TOP, LEFT, BOTTOM, RAISED, BOTH, Canvas # import controller to call/create widgets and position them in the view import controller # Construct a simple root window root = Tk() root.title("Simulation") root.protocol("WM_DELETE_WINDOW", quit) frame = Frame(root) # Place buttons simply at the top frame.pack(side=TOP) controller.reset_button(frame, text="Reset").pack(side=LEFT) controller.start_button(frame, text="Start").pack(side=LEFT) controller.stop_button(frame, text="Stop").pack(side=LEFT) controller.step_button(frame, text="Step").pack(side=LEFT) controller.object_button(frame, text="Ball").pack(side=LEFT) controller.object_button(frame, text="Floater").pack(side=LEFT) controller.object_button(frame, text="Black_Hole").pack(side=LEFT) controller.object_button(frame, text="Pulsator").pack(side=LEFT) controller.object_button(frame, text="Hunter").pack(side=LEFT) controller.object_button(frame, text="Special").pack(side=LEFT) controller.object_button(frame, text="Remove").pack(side=LEFT) controller.progress(frame, text="0 updates/0 simultons", width=25, relief=RAISED).pack(side=LEFT) # Place canvas in the space below
Created on Nov 22, 2017 @author: NeilShah-MacBookPro ''' # Executable from tkinter import Tk, Frame, TOP, BOTTOM, LEFT, BOTH import controller # Construct a root window root = Tk() root.title('The Game of Life') root.protocol('WM_DELETE_WINDOW', quit) # Place buttons at the top of the window frame = Frame(root) frame.pack(side=TOP) controller.start_button(frame, text='START').pack(side=LEFT) controller.stop_button(frame, text='STOP').pack(side=LEFT) controller.reset_button(frame, text='RESET').pack(side=LEFT) controller.generation_label(frame, text='GENERATION: 0').pack(side=LEFT) controller.grid_simulation_canvas(root, width=1000, height=1000).pack(side=BOTTOM, fill=BOTH, expand=True) if __name__ == '__main__': controller.repeater(root) root.mainloop()