def __init__(self, parent): # Dropsuit Window initialization self.parent = parent self.window = Toplevel(self.parent) self.window.resizable(width=False, height=False) self.fitting_library = FittingLibrary() self.dropsuit_library = DropsuitLibrary() # Call pertinent methods for this window. self.menu_dropsuits()
class DropsuitWindow(Frame): """ This handles the window for selecting a new dropsuit. """ def __init__(self, parent): # Dropsuit Window initialization self.parent = parent self.window = Toplevel(self.parent) self.window.resizable(width=False, height=False) self.fitting_library = FittingLibrary() self.dropsuit_library = DropsuitLibrary() # Call pertinent methods for this window. self.menu_dropsuits() def menu_dropsuits(self): """ Handles the main menu items to select a dropsuit. """ # Get known dropsuit names. self.fitting_name = StringVar() dropsuit_names = StringVar(value=self.dropsuit_library.get_names()) # Creates the widgets needed for this menu. lbl_enter_name = Label(self.window, text='Enter Dropsuit Fitting Name') ent_fitting_name = Entry(self.window, textvariable=self.fitting_name, bg='white') lbl_dropsuits = Label(self.window, text='Select Dropsuit') self.lbx_dropsuits = Listbox(self.window, listvariable=dropsuit_names, height=10, bg='white') scb_dropsuits = Scrollbar(self.window, orient=VERTICAL, command=self.lbx_dropsuits.yview) btn_cancel = Button(self.window, text='Cancel', command=self.cancel) btn_okay = Button(self.window, text='Okay', command=self.okay) # Grid management. lbl_enter_name.grid(column=0, row=0, columnspan=2, sticky=W) ent_fitting_name.grid(column=0, row=1, columnspan=2, sticky=EW) lbl_dropsuits.grid(column=0, row=2, columnspan=2, sticky=(N, W), padx=3, pady=3) self.lbx_dropsuits.grid(column=0, row=3, sticky=EW, padx=3, pady=3) scb_dropsuits.grid(column=1, row=3, sticky=NE+S) self.lbx_dropsuits['yscrollcommand'] = scb_dropsuits.set btn_cancel.grid(column=0, row=4) btn_okay.grid(column=0, row=4, columnspan=2, sticky=E) def cancel(self, *args): """ """ self.window.destroy() def okay(self, *args): # Find what is selected. listbox_index = self.lbx_dropsuits.curselection() dropsuit_name = self.lbx_dropsuits.get(listbox_index) # Pass the dropsuit to the main class DftUi self.parent.load_new_dropsuit(self.fitting_name.get(), dropsuit_name) self.window.destroy()