#GUI Group: Nora, Josh, Dylan, Denny #April 2010 #CSC323 #The single-user input screen for the Game of Life from tkinter import * class SingleUserScreen: """The SingleUserScreen, which takes input to create a single-player game""" def __init__(self, parent): parent.geometry("600x400") """Choose background colors""" self.con_myContainerLeft = Frame(parent, width=2000, bg="darkblue") self.con_myContainerRight = Frame(parent, width=2000, bg="darkblue") self.con_myContainerLeft.pack(side = TOP, fill = BOTH, expand = YES) self.con_myContainer1 = Frame(parent, width=30, bg="darkblue") """Display size text.""" sizeinfo = Label(self.con_myContainer1, text="Please enter integers for width and height.", bg="darkblue", fg="white") sizeinfo.pack(fill=X) self.con_myContainer1.pack(side = TOP, fill = BOTH, expand = YES) """Entry field for width""" self.con_size = Frame(parent, width=10, bg="darkblue") widthinfo = Label(self.con_size, text="Width:", bg="darkblue", fg="white") widthinfo.pack(fill=X) w = Entry(self.con_size) w.pack() w.delete(0, END) w.insert(0, "width") width=w.get() """Entry field for height""" heightinfo = Label(self.con_size, text="Height:", bg="darkblue", fg="white") heightinfo.pack(fill=X) h = Entry(self.con_size) h.pack() h.delete(0, END) h.insert(0, "height") height=h.get() """Drop-down menu for defaultSpecies""" specieschoice = Label(self.con_size, text="Choose a default species:", bg="darkblue", fg="white") specieschoice.pack(fill=X) """Menu using Listbox""" listbox = Listbox(self.con_size, height=5) listbox.pack(side=TOP, fill=NONE, expand=NO) for item in ["Blank", "Professor", "Squirrel", "FM"]: listbox.insert(END, item) self.con_size.pack(side = TOP, fill = BOTH, expand = YES) """Menu using Radiobutton""" # v = IntVar() # Radiobutton(root2, text="Blank Species", variable=v, # value=1, fg="white", bg="darkblue", # width=200, bd=0).pack(anchor=CENTER) # Radiobutton(root2, text="Professor ", variable=v, # value=2, fg="white", bg="darkblue", # width=200, bd=0).pack(anchor=CENTER) # Radiobutton(root2, text="Squirrel ", variable=v, # value=3, fg="white", bg="darkblue", # width=200, bd=0).pack(anchor=CENTER) # Radiobutton(root2, text="FM ", variable=v, # value=4, fg="white", bg="darkblue", # width=200, bd=0).pack(anchor=CENTER) """Build my board! button""" self.frm_ButtonLayout = Frame(parent, width=15, bg="darkblue") self.frm_ButtonLayout.pack(side=TOP, fill=NONE, expand=NO) self.btn_Build = Button(self.frm_ButtonLayout, text="Build my board!", width=15, background="white") self.btn_Build.pack() """Back button""" self.btn_Back = Button(self.frm_ButtonLayout, text="Main Menu", width=15, background="white") self.btn_Back.bind("", self.MainMenu) self.btn_Back.pack() """Fill the rest of the screen""" self.con_myContainerRight.pack(side = TOP, fill = BOTH, expand = YES) """Bind the MainMenu button""" def MainMenu(self, event): root2.destroy() import MainMenu quit() root2 = Tk() whatever1 = SingleUserScreen(root2) root2.wm_title("Single-Player Game Setup") root2.mainloop()