def refresh_conditions(self, lb, sb, condition_dir): # lb = tk.ListBox of conditions # sb = tk.Scrollbar of conditions self.condition_list = fGl.get_subdir_names(condition_dir) try: lb.delete(0, tk.END) except: pass for e in self.condition_list: lb.insert(tk.END, e) sb.config(command=lb.yview)
def refresh_listbox(self, lb, sb, mdir): """ Refreshes ListBox as a function of folder names in mdir :param lb: ListBox :param sb: ScrollBar :param mdir: directory with subfolders :return: None """ # lb = tk.ListBox of conditions # sb = tk.Scrollbar of conditions try: lb.delete(0, tk.END) except: pass for e in fGl.get_subdir_names(mdir): lb.insert(tk.END, e) sb.config(command=lb.yview)
def __init__(self, master=None): self.condition_list = fGl.get_subdir_names(config.dir2ra + "01_Conditions\\") self.condition = "" self.errors = False self.features = cDef.FeatureDefinitions() self.feature_id_list = [] self.feature_name_list = [] self.logger = logging.getLogger("logfile") self.reaches = cDef.ReachDefinitions() self.reach_ids_applied = [ ] # self.reaches.id_xlsx ## initial: all reaches (IDs) self.reach_lookup_needed = False self.reach_names_applied = [ ] # self.reaches.names_xlsx ## initial: all reaches (full names) self.reach_template_dir = config.dir2mt + ".templates\\" self.reader = cRM.Read() self.unit = "us" self.q_unit = "cfs" self.h_unit = "ft" self.u_unit = "ft/s" self.verified = False self.ww = int() # window width self.wh = int() # window height self.wx = int() self.wy = int() self.xd = 5 # distance holder in x-direction (pixel) self.yd = 5 # distance holder in y-direction (pixel) # Construct the Frame object. tk.Frame.__init__(self, master) # if imported from master GUI, redefine master as highest level (ttk.Notebook tab container) if __name__ != '__main__': self.master = self.winfo_toplevel() self.pack(expand=True, fill=tk.BOTH) # tkinter standard object self.l_reaches = tk.Label(self) self.make_standard_menus()
def update_flows(self): try: self.lb_flow.delete( 0, tk.END) # try to empty listbox if currently filled except: pass # update depth raster file list from condition folder contents (raster has .aux.xml?) self.h_list = ["all terrain"] folder_names = fGl.get_subdir_names(self.dir_input_ras) if folder_names.__len__() < 1: folder_names = [ i for i in os.listdir(self.dir_input_ras) if i.endswith('.tif') ] for fn in folder_names: if fn[0] == "h": if os.path.isdir(self.dir_input_ras + fn) or os.path.isfile(self.dir_input_ras + fn): self.h_list.append(fn) for e in self.h_list: self.lb_flow.insert(tk.END, e) self.sb_flow.config(command=self.lb_flow.yview)
def __init__(self, master): top = self.top = tk.Toplevel(master) self.condition_list = fGl.get_subdir_names(config.dir2conditions) self.dir2condition_act = '.' self.dir2dem = '' self.dir2h = '' self.dir2u = '' self.unit = "us" self.unit_dict = {"us": "U.S. customary", "si": "SI (metric)"} # define analysis type identifiers (default = False) self.bool_var = tk.BooleanVar() self.top.iconbitmap(config.code_icon) # ARRANGE GEOMETRY # width and height of the window. ww = 650 wh = 570 self.xd = 5 # distance holder in x-direction (pixel) self.yd = 5 # distance holder in y-direction (pixel) # height and location wx = (self.top.winfo_screenwidth() - ww) / 2 wy = (self.top.winfo_screenheight() - wh) / 2 self.top.geometry("%dx%d+%d+%d" % (ww, wh, wx, wy)) self.top.title("Populate Condition") # window title self.col_0_width = 25 # Set Condition self.l_name = tk.Label(top, text="Select condition: ") self.l_name.grid(sticky=tk.W, row=0, rowspan=3, column=0, padx=self.xd, pady=self.yd) self.sb_condition = tk.Scrollbar(top, orient=tk.VERTICAL) self.sb_condition.grid(sticky=tk.W, row=0, column=2, padx=0, pady=self.yd) self.lb_condition = tk.Listbox(top, height=3, width=15, yscrollcommand=self.sb_condition.set) for ce in self.condition_list: self.lb_condition.insert(tk.END, ce) self.lb_condition.grid(sticky=tk.EW, row=0, column=1, padx=0, pady=self.yd) self.sb_condition.config(command=self.lb_condition.yview) self.b_sc = tk.Button(top, width=self.col_0_width - 5, fg="firebrick3", bg="white", text="Validate", command=lambda: self.set_condition()) self.b_sc.grid(sticky=tk.E, row=0, rowspan=3, column=2, padx=self.xd, pady=self.yd) self.l_c_dir = tk.Label(top, fg="firebrick3", text="Select a condition.") self.l_c_dir.grid(sticky=tk.W, row=3, column=0, columnspan=4, padx=self.xd, pady=self.yd) tk.Label(top, text="").grid(sticky=tk.W, row=4, column=0) # dummy # 02 Make d2w self.l_d2w = tk.Label( top, text="Create Depth to Groundwater Raster (d2w.tif)") self.l_d2w.grid(sticky=tk.W, row=5, column=0, columnspan=4, padx=self.xd, pady=self.yd) self.b_sd2w = tk.Button(top, width=self.col_0_width * 2, bg="white", text="Select minimum flow depth raster", command=lambda: self.select_h()) self.b_sd2w.grid(sticky=tk.EW, row=6, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.b_d2w = tk.Button(top, width=self.col_0_width, bg="white", text="Run d2w creation", command=lambda: self.run_d2w()) self.b_d2w.grid(sticky=tk.EW, row=6, column=2, padx=self.xd, pady=self.yd) self.l_interp = tk.Label(top, text="Interpolation method:") self.l_interp.grid(sticky=tk.W, row=7, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.c_interp = ttk.Combobox(top, state='readonly') self.c_interp.grid(sticky=tk.W, row=7, column=1, padx=self.xd, pady=self.yd) self.c_interp["values"] = ("IDW", "EBK", "Kriging", "Nearest Neighbor") self.c_interp.current(0) self.l_d2w_dem = tk.Label(top, text="") self.l_d2w_dem.grid(sticky=tk.W, row=8, column=0, columnspan=4, padx=self.xd, pady=self.yd) tk.Label(top, text="").grid(sticky=tk.W, row=9, column=0) # dummy # 03 Make detDEM self.l_det = tk.Label( top, text="Create detrended DEM Raster (dem_detrend.tif)") self.l_det.grid(sticky=tk.W, row=9, column=0, columnspan=4, padx=self.xd, pady=self.yd) self.b_sdet = tk.Button(top, width=self.col_0_width * 2, bg="white", text="Select minimum flow depth raster", command=lambda: self.select_h()) self.b_sdet.grid(sticky=tk.EW, row=10, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.b_det = tk.Button(top, width=self.col_0_width, bg="white", text="Run detrended DEM creation", command=lambda: self.run_det()) self.b_det.grid(sticky=tk.EW, row=10, column=2, padx=self.xd, pady=self.yd) self.l_det_dem = tk.Label(top, text="") self.l_det_dem.grid(sticky=tk.W, row=11, column=0, columnspan=4, padx=self.xd, pady=self.yd) tk.Label(top, text="").grid(sticky=tk.W, row=12, column=0) # dummy # 04 Make MU self.l_mu = tk.Label(top, text="Create Morphological Unit Raster (mu.tif)") self.l_mu.grid(sticky=tk.W, row=13, column=0, columnspan=4, padx=self.xd, pady=self.yd) self.b_smuh = tk.Button(top, width=self.col_0_width, bg="white", text="Select depth raster", command=lambda: self.select_h()) self.b_smuh.grid(sticky=tk.EW, row=14, column=0, padx=self.xd, pady=self.yd) self.b_smuu = tk.Button(top, width=self.col_0_width, bg="white", text="Select velocity raster", command=lambda: self.select_u()) self.b_smuu.grid(sticky=tk.EW, row=14, column=1, padx=self.xd, pady=self.yd) self.b_chg_mu = tk.Button(top, width=self.col_0_width * 2 + self.xd * 2, bg="white", text="View / change MU definitions", command=lambda: self.open_mu_xlsx()) self.b_chg_mu.grid(sticky=tk.EW, row=15, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.b_mu = tk.Button(top, width=self.col_0_width, bg="white", text="Run MU\ncreation", command=lambda: self.run_mu()) self.b_mu.grid(sticky=tk.EW, row=14, rowspan=2, column=2, padx=self.xd, pady=self.yd) self.l_mu_unit = tk.Label( top, fg="dodger blue", text="Currently selected Raster unit system: % s" % self.unit_dict[self.unit]) self.l_mu_unit.grid(sticky=tk.W, row=16, column=0, columnspan=4, padx=self.xd, pady=self.yd) # tk.Label(top, text="").grid(sticky=tk.W, row=15, column=0) # dummy self.b_return = tk.Button(top, width=self.col_0_width, fg="RoyalBlue3", bg="white", text="RETURN to MAIN WINDOW", command=lambda: self.gui_quit()) self.b_return.grid(sticky=tk.E, row=17, column=2, padx=self.xd, pady=self.yd) # add units-menu self.mbar = tk.Menu(self.top, foreground="dodger blue") # create new menubar self.top.config(menu=self.mbar) # attach it to the root window self.unitmenu = tk.Menu(self.mbar, tearoff=0, foreground="dodger blue") # create new menu self.mbar.add_cascade( label="Units", menu=self.unitmenu, foreground="dodger blue") # attach it to the menubar self.unitmenu.add_command(label="[current] U.S. customary", background="pale green") self.unitmenu.add_command(label="[ ] SI (metric)", command=lambda: self.unit_change()) self.b_d2w["state"] = "disabled" self.b_det["state"] = "disabled" self.b_mu["state"] = "disabled" self.b_sd2w["state"] = "disabled" self.c_interp["state"] = "disabled" self.b_sdet["state"] = "disabled" self.b_smuh["state"] = "disabled" self.b_smuu["state"] = "disabled" try: fGl.clean_dir(config.dir2gs + ".cache\\") fGl.rm_dir(config.dir2gs + ".cache\\") except: pass
def __init__(self, from_master): sg.RaModuleGui.__init__(self, from_master) self.ww = 750 # window width self.wh = 650 # window height self.title = "Modify Terrain" self.set_geometry(self.ww, self.wh, self.title) self.in_feat = config.dir2ml + "Output\\Rasters\\" self.prevent_popup = False # GUI OBJECT VARIABLES self.gui_condition = tk.StringVar() self.gui_interpreter = tk.StringVar() self.mapping = tk.BooleanVar() # LABELS self.l_reach_label = tk.Label(self, fg="dark slate gray", text="Reaches:") self.l_reach_label.grid(sticky=tk.W, row=0, column=0, padx=self.xd, pady=self.yd) self.l_reaches.config(fg="red", text="Select from Reaches menu") self.l_reaches.grid(sticky=tk.W, row=0, column=1, columnspan=5, padx=self.xd, pady=self.yd) self.l_condition = tk.Label(self, text="Select condition:") self.l_condition.grid(sticky=tk.W, row=0, column=0, padx=self.xd, pady=self.yd) self.l_inpath_curr = tk.Label(self, fg="gray60", text="Source: " + config.dir2conditions) self.l_inpath_curr.grid(sticky=tk.W, row=1, column=0, columnspan=3, padx=self.xd, pady=self.yd) self.combo_c = ttk.Combobox(self) self.combo_c.grid(sticky=tk.W, row=0, column=1, padx=self.xd, pady=self.yd) self.combo_c['values'] = tuple( fGl.get_subdir_names(config.dir2conditions)) self.combo_c['state'] = 'readonly' # BUTTONS self.b_s_condition = tk.Button(self, fg="red", text="Select Condition", command=lambda: self.select_condition()) self.b_s_condition.grid(sticky=tk.W, row=0, column=3, columnspan=2, padx=self.xd, pady=self.yd) # THRESHOLD-MOD FRAME self.th_mod = ThresholdFrame(self, relief=tk.RAISED) self.set_bg_color(self.th_mod, "light grey") self.th_mod.grid(row=4, column=0, columnspan=2) self.th_mod.l_inpath_feat.config(text=str(self.in_feat)) self.th_mod.b_run_grade.config( command=lambda: self.run_modification("grade")) self.th_mod.b_run_widen.config( command=lambda: self.run_modification("widen")) # RIVERBUILDER FRAME self.rb = RiverBuilderFrame(self, self.unit, relief=tk.RAISED) self.set_bg_color(self.rb, "LightBlue1") self.rb.grid(row=4, column=3, columnspan=2) self.complete_menus()
def __init__(self, master, unit, fish_applied, *args): top = self.top = tk.Toplevel(master) self.dir_input_ras = "" self.condition = "" self.condition_list = fGl.get_subdir_names(config.dir2conditions) self.max_columnspan = 5 self.discharge_xlsx = [] self.unit = unit self.fish_applied = fish_applied self.top.iconbitmap(config.code_icon) try: # test if a boundary shapefile was provided self.boundary_shp = args[0] except: self.boundary_shp = "" # ARRANGE GEOMETRY # width and height of the window. ww = 420 wh = 307 self.xd = 5 # distance holder in x-direction (pixel) self.yd = 5 # distance holder in y-direction (pixel) # height and location wx = (self.top.winfo_screenwidth() - ww) / 2 wy = (self.top.winfo_screenheight() - wh) / 2 self.top.geometry("%dx%d+%d+%d" % (ww, wh, wx, wy)) self.top.title("Generate hydraulic habitat condition (HSI) Rasters") # window title self.l_condition = tk.Label(top, text="Select a hydraulic Condition:") self.l_condition.grid(sticky=tk.W, row=2, rowspan=3, column=0, padx=self.xd, pady=self.yd) self.l_inpath_curr = tk.Label(top, fg="gray60", text="Source: "+str(config.dir2conditions)) self.l_inpath_curr.grid(sticky=tk.W, row=5, column=0, columnspan=self.max_columnspan + 1, padx=self.xd, pady=self.yd) self.l_dummy = tk.Label(top, text=" ") self.l_dummy.grid(sticky=tk.W, row=2, column=self.max_columnspan, padx=self.xd, pady=self.yd) self.l_run_info = tk.Label(top, text="") self.l_run_info.grid(sticky=tk.W, row=8, column=0, columnspan=self.max_columnspan - 1, padx=self.xd, pady=self.yd) # DROP DOWN ENTRIES (SCROLL BARS) self.sb_condition = tk.Scrollbar(top, orient=tk.VERTICAL) self.sb_condition.grid(sticky=tk.W, row=2, column=2, padx=0, pady=self.yd) self.lb_condition = tk.Listbox(top, height=3, width=15, yscrollcommand=self.sb_condition.set) for e in self.condition_list: self.lb_condition.insert(tk.END, e) self.lb_condition.grid(sticky=tk.E, row=2, column=1, padx=self.xd, pady=self.yd) self.sb_condition.config(command=self.lb_condition.yview) # BUTTONS iflow = "Flow data are looked up from the selected Condition and Physical Habitat" self.l_flowdur = tk.Label(top, bg="white", text=iflow) self.l_flowdur.grid(sticky=tk.EW, row=1, column=0, columnspan=self.max_columnspan, padx=self.xd, pady=self.yd) self.b_c_select = tk.Button(top, width=8, bg="white", text="Select", command=lambda: self.select_condition()) self.b_c_select.grid(sticky=tk.W, row=2, rowspan=3, column=self.max_columnspan - 1, padx=self.xd, pady=self.yd) self.b_Q = tk.Button(top, fg="RoyalBlue3", width=30, bg="white", text=" Optional: View discharge dependency file (xlsx workbook)", anchor='w', command=lambda: self.user_message("Confirm hydraulic Condition first!")) self.b_Q.grid(sticky=tk.EW, row=6, column=0, columnspan=self.max_columnspan, padx=self.xd, pady=self.yd) self.b_HSC = tk.Button(top, width=30, bg="white", text=" Optional: Edit Habitat Suitability Curves", anchor='w', command=lambda: self.open_files([config.xlsx_aqua])) self.b_HSC.grid(sticky=tk.EW, row=7, column=0, columnspan=self.max_columnspan, padx=self.xd, pady=self.yd) self.b_run = tk.Button(top, width=30, bg="white", text="Run (generate habitat condition)", anchor='w', command=lambda: self.run_raster_calc()) self.b_run.grid(sticky=tk.EW, row=8, column=0, columnspan=self.max_columnspan, padx=self.xd, pady=self.yd) self.b_run["state"] = "disabled" self.b_return = tk.Button(top, fg="RoyalBlue3", bg="white", text="RETURN to MAIN WINDOW", command=lambda: self.gui_quit()) self.b_return.grid(sticky=tk.E, row=9, column=0, columnspan=self.max_columnspan, padx=self.xd, pady=self.yd)
def __init__(self, master): top = self.top = tk.Toplevel(master) self.condition_list = fGl.get_subdir_names(config.dir2conditions) self.dir2src_condition = '.' self.dir2sub_condition = '.' self.dir2bound = '.' self.sub_condition_name = tk.StringVar() self.top.iconbitmap(config.code_icon) # ARRANGE GEOMETRY # width and height of the window. ww = 455 wh = 370 self.xd = 5 # distance holder in x-direction (pixel) self.yd = 5 # distance holder in y-direction (pixel) # height and location wx = (self.top.winfo_screenwidth() - ww) / 2 wy = (self.top.winfo_screenheight() - wh) / 2 self.top.geometry("%dx%d+%d+%d" % (ww, wh, wx, wy)) self.top.title("Create Sub Condition") # window title self.col_0_width = 25 # 01 Select source Condition self.l_name = tk.Label(top, text="Select source condition: ") self.l_name.grid(sticky=tk.W, row=0, rowspan=3, column=0, padx=self.xd, pady=self.yd) self.sb_condition = tk.Scrollbar(top, orient=tk.VERTICAL) self.sb_condition.grid(sticky=tk.W, row=0, column=2, padx=0, pady=self.yd) self.lb_condition = tk.Listbox(top, height=3, width=15, yscrollcommand=self.sb_condition.set) for ce in self.condition_list: self.lb_condition.insert(tk.END, ce) self.lb_condition.grid(sticky=tk.EW, row=0, column=1, padx=0, pady=self.yd) self.sb_condition.config(command=self.lb_condition.yview) self.b_sc = tk.Button(top, width=self.col_0_width - 5, fg="firebrick3", bg="white", text="Validate", command=lambda: self.select_src_condition()) self.b_sc.grid(sticky=tk.E, row=0, rowspan=3, column=2, padx=self.xd, pady=self.yd) self.l_c_dir = tk.Label(top, fg="firebrick3", text="Select a condition.") self.l_c_dir.grid(sticky=tk.W, row=3, column=0, columnspan=3, padx=self.xd, pady=self.yd) tk.Label(top, text="").grid(sticky=tk.W, row=4, column=0) # dummy # 02 Define sub condition name self.l_name = tk.Label(top, text="Sub-Condition name: ") self.l_name.grid(sticky=tk.W, row=5, column=0, padx=self.xd, pady=self.yd) self.e_condition = tk.Entry(top, textvariable=self.sub_condition_name) self.e_condition.grid(sticky=tk.EW, row=5, column=1, columnspan=2, padx=self.xd, pady=self.yd) tk.Label(top, text="").grid(sticky=tk.W, row=6, column=0) # dummy # 03 Define spatial boundary raster self.b_bound = tk.Button( top, bg="white", text="Select spatial boundary Shapefile or Raster", command=lambda: self.select_boundary()) self.b_bound.grid(sticky=tk.EW, row=7, column=0, columnspan=3, padx=self.xd, pady=self.yd) self.l_bound = tk.Label(top, fg="red", text="No spatial boundary Raster defined.", width=self.col_0_width * 2) self.l_bound.grid(sticky=tk.W, row=8, column=0, columnspan=3, padx=self.xd, pady=self.yd) tk.Label(top, text="").grid(sticky=tk.W, row=9, column=0) # dummy # 04 CREATE SUB-CONDITION self.b_create_c = tk.Button(top, bg="white", text="CREATE SUB-CONDITION", command=lambda: self.run_sub_c()) self.b_create_c.grid(sticky=tk.EW, row=10, column=0, columnspan=3, padx=self.xd, pady=self.yd) self.l_run_info = tk.Label(top, fg="forest green", text="") self.l_run_info.grid(sticky=tk.W, row=11, column=0, columnspan=3, padx=self.xd, pady=self.yd) self.b_return = tk.Button(top, width=self.col_0_width, fg="RoyalBlue3", bg="white", text="RETURN to MAIN WINDOW", command=lambda: self.gui_quit()) self.b_return.grid(sticky=tk.E, row=12, column=2, padx=self.xd, pady=self.yd)
def __init__(self, master): top = self.top = tk.Toplevel(master) self.condition_list = fGl.get_subdir_names(config.dir2conditions) self.condition = '' self.dir2snap = '' # ARRANGE GEOMETRY # width and height of the window. ww = 500 wh = 200 self.xd = 5 # distance holder in x-direction (pixel) self.yd = 5 # distance holder in y-direction (pixel) # height and location wx = (self.top.winfo_screenwidth() - ww) / 2 wy = (self.top.winfo_screenheight() - wh) / 2 self.top.geometry("%dx%d+%d+%d" % (ww, wh, wx, wy)) self.top.title("Align Input Rasters") # window title self.top.iconbitmap(config.code_icon) row = 0 # select condition self.l_condition = tk.Label(top, text="Select condition:") self.l_condition.grid(sticky=tk.W, row=row, column=0, padx=self.xd, pady=self.yd) self.combo_c = ttk.Combobox(top) self.combo_c.grid(sticky=tk.W, row=row, column=1) self.combo_c['values'] = tuple( fGl.get_subdir_names(config.dir2conditions)) self.combo_c['state'] = 'readonly' self.b_s_condition = tk.Button(top, fg="red", text="Select", command=lambda: self.select_condition()) self.b_s_condition.grid(sticky=tk.W, row=row, column=2, columnspan=2) row += 1 self.l_inpath_curr = tk.Label(top, fg="gray60", text="Source: " + config.dir2conditions) self.l_inpath_curr.grid(sticky=tk.W, row=row, column=0, columnspan=4, padx=self.xd, pady=self.yd) row += 1 self.b_snap_ras = tk.Button(top, width=30, text="Select alignment raster", command=lambda: self.select_snap_ras()) self.b_snap_ras.grid(sticky=tk.W, row=row, column=0, columnspan=3, padx=self.xd, pady=self.yd) row += 1 self.l_snap_ras = tk.Label(top, fg="red", text="No alignment raster selected.") self.l_snap_ras.grid(sticky=tk.W, row=row, column=0, columnspan=3, padx=self.xd, pady=self.yd) row += 1 self.b_align = tk.Button(top, width=30, text="Align Rasters", command=lambda: self.align_rasters()) self.b_align.grid(sticky=tk.W, row=row, column=0, columnspan=3, padx=self.xd, pady=self.yd) self.b_align["state"] = "disabled"
def __init__(self, master): top = self.top = tk.Toplevel(master) self.condition = "" self.condition_list = fGl.get_subdir_names(config.dir2conditions) self.dir2condition_act = '.' self.dir2dem = '' self.dir2h = '' self.dir2u = '' self.eco_flow_type = cFi.Fish() self.eco_flow_type_applied = {} self.eco_flow_type_list = [] self.flows_xlsx = '' self.flow_series_xlsx = None self.logger = logging.getLogger("logfile") # define analysis type identifiers (default = False) self.bool_var = tk.BooleanVar() self.top.iconbitmap(config.code_icon) # ARRANGE GEOMETRY # width and height of the window. ww = 590 wh = 370 self.xd = 5 # distance holder in x-direction (pixel) self.yd = 5 # distance holder in y-direction (pixel) # height and location wx = (self.top.winfo_screenwidth() - ww) / 2 wy = (self.top.winfo_screenheight() - wh) / 2 self.top.geometry("%dx%d+%d+%d" % (ww, wh, wx, wy)) self.top.title("Analyze Discharge") # window title self.col_0_width = 25 # Set Condition self.l_0 = tk.Label(top, text="1) Analyze a Condition") self.l_0.grid(sticky=tk.W, row=0, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.l_name = tk.Label(top, text="Select condition: ") self.l_name.grid(sticky=tk.W, row=1, rowspan=3, column=0, padx=self.xd, pady=self.yd) self.sb_condition = tk.Scrollbar(top, orient=tk.VERTICAL) self.sb_condition.grid(sticky=tk.W, row=1, column=2, padx=0, pady=self.yd) self.lb_condition = tk.Listbox(top, height=3, width=15, yscrollcommand=self.sb_condition.set) for ce in self.condition_list: self.lb_condition.insert(tk.END, ce) self.lb_condition.grid(sticky=tk.EW, row=1, column=1, padx=0, pady=self.yd) self.sb_condition.config(command=self.lb_condition.yview) self.b_sc = tk.Button(top, width=self.col_0_width - 5, fg="firebrick3", bg="white", text="Analyze", command=lambda: self.scan_condition()) self.b_sc.grid(sticky=tk.E, row=1, rowspan=3, column=2, padx=self.xd, pady=self.yd) self.l_c_dir = tk.Label( top, fg="firebrick3", text="Select a condition and press \'Analyze\'.") self.l_c_dir.grid(sticky=tk.W, row=4, column=0, columnspan=4, padx=self.xd, pady=self.yd) tk.Label(top, text="").grid(sticky=tk.W, row=5, column=0) # dummy # 02 Make input file for condition self.l_1 = tk.Label(top, text="2) Generate Flow Duration Curves") self.l_1.grid(sticky=tk.W, row=6, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.b_mod = tk.Button(top, bg="white", text="Modify Source", command=lambda: self.modify_eco_flow_source()) self.b_mod.grid(sticky=tk.E, row=6, column=2, padx=self.xd, pady=self.yd) self.l_s_type = tk.Label(top, text="Add season / target species: ") self.l_s_type.grid(sticky=tk.W, row=7, rowspan=3, column=0, padx=self.xd, pady=self.yd) self.sb_type = tk.Scrollbar(top, orient=tk.VERTICAL) self.sb_type.grid(sticky=tk.W, row=7, column=2, padx=0, pady=self.yd) self.lb_type = tk.Listbox(top, height=3, width=25, yscrollcommand=self.sb_type.set) self.lb_type.grid(sticky=tk.EW, row=7, column=1, padx=0, pady=self.yd) self.make_eco_type_list(rebuild=False) self.b_sct = tk.Button(top, fg="firebrick3", width=self.col_0_width - 5, bg="white", text="Add", command=lambda: self.select_eco_type()) self.b_sct.grid(sticky=tk.E, row=7, rowspan=3, column=2, padx=self.xd, pady=self.yd) self.l_ct_dir = tk.Label(top, text="Current selection: {0}".format( fGl.print_dict( self.eco_flow_type_applied))) self.l_ct_dir.grid(sticky=tk.W, row=10, column=0, columnspan=4, padx=self.xd, pady=self.yd) self.b_q_inp = tk.Button( top, width=self.col_0_width * 2, fg="firebrick3", bg="white", text="Select input Flow Series", command=lambda: self.select_flow_series_xlsx()) self.b_q_inp.grid(sticky=tk.EW, row=11, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.b_q_dur = tk.Button(top, width=self.col_0_width * 2, fg="firebrick3", bg="white", text="Make flow duration curve(s)", command=lambda: self.make_flow_duration()) self.b_q_dur.grid(sticky=tk.EW, row=12, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.b_sct["state"] = "disabled" self.b_q_inp["state"] = "disabled" self.b_q_dur["state"] = "disabled" self.b_return = tk.Button(top, width=self.col_0_width, fg="RoyalBlue3", bg="white", text="RETURN to MAIN WINDOW", command=lambda: self.gui_quit()) self.b_return.grid(sticky=tk.E, row=12, column=2, padx=self.xd, pady=self.yd)
def __init__(self, master, unit, fish_applied): top = self.top = tk.Toplevel(master) self.cover_applies = False self.dir_input_ras = "" self.condition = "" self.condition_list = fGl.get_subdir_names(config.dir2conditions) self.flow_path = "" # full path to whetted-region defining raster self.h_list = ["all terrain"] self.h_ras_path = "" self.max_columnspan = 5 self.unit = unit self.fish_applied = fish_applied # define analysis type identifiers (default = False) self.substrate = tk.BooleanVar() self.boulders = tk.BooleanVar() self.cobbles = tk.BooleanVar() self.wood = tk.BooleanVar() self.plants = tk.BooleanVar() self.hsi_types = { "substrate": self.substrate, "boulders": self.boulders, "cobbles": self.cobbles, "wood": self.wood, "plants": self.plants } self.top.iconbitmap(config.code_icon) # ARRANGE GEOMETRY # width and height of the window. ww = 570 wh = 475 self.xd = 5 # distance holder in x-direction (pixel) self.yd = 5 # distance holder in y-direction (pixel) # height and location wx = (self.top.winfo_screenwidth() - ww) / 2 wy = (self.top.winfo_screenheight() - wh) / 2 self.top.geometry("%dx%d+%d+%d" % (ww, wh, wx, wy)) self.top.title( "Generate cover habitat condition rasters") # window title act_row = 0 # Select condition ROWs 0 - 3 self.l_condition = tk.Label(top, text="1) Select condition:") self.l_condition.grid(sticky=tk.W, row=act_row, rowspan=3, column=0, padx=self.xd, pady=self.yd) self.l_dummy = tk.Label( top, text= " " ) self.l_dummy.grid(sticky=tk.W, row=act_row, column=self.max_columnspan, padx=self.xd, pady=self.yd) self.sb_condition = tk.Scrollbar(top, orient=tk.VERTICAL) self.sb_condition.grid(sticky=tk.W, row=act_row, column=2, padx=0, pady=self.yd) self.lb_condition = tk.Listbox(top, height=3, width=15, yscrollcommand=self.sb_condition.set) for e in self.condition_list: self.lb_condition.insert(tk.END, e) self.lb_condition.grid(sticky=tk.E, row=act_row, column=1, padx=self.xd, pady=self.yd) self.sb_condition.config(command=self.lb_condition.yview) self.b_c_select = tk.Button(top, width=8, bg="white", text="Confirm\nselection", command=lambda: self.select_condition()) self.b_c_select.grid(sticky=tk.W, row=act_row, rowspan=3, column=self.max_columnspan - 1, padx=self.xd, pady=self.yd) msg_hc1 = "Highlight one condition (located in the 01_Conditions folder)." self.b_h_con = tk.Button(top, fg="RoyalBlue3", bg="white", text="Help", command=lambda: self.user_message(msg_hc1)) self.b_h_con.grid(sticky=tk.W, row=act_row, column=self.max_columnspan, padx=self.xd, pady=self.yd) act_row += 3 self.l_inpath_curr = tk.Label(top, fg="gray60", text="Source: " + str(config.dir2conditions)) self.l_inpath_curr.grid(sticky=tk.W, row=act_row, column=0, columnspan=self.max_columnspan + 1, padx=self.xd, pady=self.yd) act_row += 1 # Select flow cover raster ROWs 4 - 7 self.l_flow = tk.Label(top, text="2) Define flow region:") self.l_flow.grid(sticky=tk.W, row=act_row, rowspan=3, column=0, padx=self.xd, pady=self.yd) self.l_dummy2 = tk.Label( top, text= " " ) self.l_dummy2.grid(sticky=tk.W, row=act_row, column=self.max_columnspan, padx=self.xd, pady=self.yd) self.sb_flow = tk.Scrollbar(top, orient=tk.VERTICAL) self.sb_flow.grid(sticky=tk.W, row=act_row, column=2, padx=0, pady=self.yd) self.lb_flow = tk.Listbox(top, height=3, width=15, yscrollcommand=self.sb_flow.set) for e in self.h_list: self.lb_flow.insert(tk.END, e) self.lb_flow.grid(sticky=tk.E, row=act_row, column=1, padx=self.xd, pady=self.yd) self.sb_flow.config(command=self.lb_flow.yview) self.b_c_select = tk.Button(top, width=8, bg="white", text="Confirm\nselection", command=lambda: self.select_flow()) self.b_c_select.grid(sticky=tk.W, row=act_row, rowspan=3, column=self.max_columnspan - 1, padx=self.xd, pady=self.yd) msg_flow1 = "Once a condition was selected, the flow region box lists the available flow depth rasters in the condition\'s folder.\n" msg_flow2 = "The selected flow depth raster defines where cover applies and excludes areas where the flow depth is smaller than the smallest value defined in Fish.xlsx or NaN." self.b_h_flow = tk.Button( top, fg="RoyalBlue3", bg="white", text="Help", command=lambda: self.user_message(msg_flow1 + msg_flow2)) self.b_h_flow.grid(sticky=tk.W, row=act_row, column=self.max_columnspan, padx=self.xd, pady=self.yd) act_row += 3 self.l_inflow_curr = tk.Label(top, fg="gray60", text="Current: " + str(self.flow_path)) self.l_inflow_curr.grid(sticky=tk.W, row=act_row, column=0, columnspan=self.max_columnspan + 1, padx=self.xd, pady=self.yd) act_row += 1 # Select type ROW self.l_select_msg = tk.Label(top, text="3) Select (cover) type(s) ") self.l_select_msg.grid(sticky=tk.W, row=act_row, column=0, columnspan=self.max_columnspan - 1, padx=self.xd, pady=self.yd) self.b_edit_hsc = tk.Button( top, fg="RoyalBlue3", bg="white", text="Edit HSCs", command=lambda: self.open_files([config.xlsx_aqua])) self.b_edit_hsc.grid(sticky=tk.EW, row=act_row, column=self.max_columnspan - 1, padx=self.xd, pady=self.yd) act_row += 1 msg_0 = "The applied Habitat Suitability Curves can be adapted by clicking on the Edit HSCs button." # SUBSTRATE ROW self.cb_substrate = tk.Checkbutton( top, text="Make substrate HSI raster", variable=self.substrate, onvalue=True, offvalue=False, command=lambda: self.print_msg("Substrate: " + str(self.substrate. get()))) self.cb_substrate.grid(sticky=tk.W, row=act_row, column=0, columnspan=self.max_columnspan - 1, padx=self.xd, pady=self.yd) msg_s1 = "If this box is checked, a substrate_hsi raster is created in the SHArC/HSI/" + self.condition + "folder.\n" msg_s2 = "A dmean raster is needed in the 01_Conditions/" + self.condition + " folder.\n" self.b_h_subs = tk.Button( top, fg="RoyalBlue3", bg="white", text="Help", command=lambda: self.user_message(msg_s1 + msg_s2 + msg_0)) self.b_h_subs.grid(sticky=tk.EW, row=act_row, column=self.max_columnspan - 1, padx=self.xd, pady=self.yd) act_row += 1 # BOULDER ROW self.cb_bou = tk.Checkbutton( top, text="Make boulder HSI raster", variable=self.boulders, onvalue=True, offvalue=False, command=lambda: self.print_msg("Boulders: " + str(self.boulders. get()))) self.cb_bou.grid(sticky=tk.W, row=act_row, column=0, columnspan=self.max_columnspan - 1, padx=self.xd, pady=self.yd) msg_b1 = "If this box is checked, a boulder_hsi raster is created in the SHArC/HSI/" + self.condition + "folder.\n" msg_b2 = "A boulders.shp delineation shapefile (polygon) is needed in the 01_Conditions/" + self.condition + " folder.\n" self.b_h_bou = tk.Button( top, fg="RoyalBlue3", bg="white", text="Help", command=lambda: self.user_message(msg_b1 + msg_b2 + msg_0)) self.b_h_bou.grid(sticky=tk.EW, row=act_row, column=self.max_columnspan - 1, padx=self.xd, pady=self.yd) act_row += 1 # COBBLE ROW self.cb_cob = tk.Checkbutton( top, text="Make cobble HSI raster", variable=self.cobbles, onvalue=True, offvalue=False, command=lambda: self.print_msg("Cobbles: " + str(self.cobbles.get( )))) self.cb_cob.grid(sticky=tk.W, row=act_row, column=0, columnspan=self.max_columnspan - 1, padx=self.xd, pady=self.yd) msg_c1 = "If this box is checked, a cobble_hsi raster is created in the SHArC/HSI/" + self.condition + "folder.\n" msg_c2 = "A dmean raster is needed in the 01_Conditions/" + self.condition + " folder.\n" self.b_h_cob = tk.Button( top, fg="RoyalBlue3", bg="white", text="Help", command=lambda: self.user_message(msg_c1 + msg_c2 + msg_0)) self.b_h_cob.grid(sticky=tk.EW, row=act_row, column=self.max_columnspan - 1, padx=self.xd, pady=self.yd) act_row += 1 # STREAMWOOD ROW self.cb_wood = tk.Checkbutton( top, text="Make streamwood HSI raster", variable=self.wood, onvalue=True, offvalue=False, command=lambda: self.print_msg("Streamwood: " + str(self.wood.get( )))) self.cb_wood.grid(sticky=tk.W, row=act_row, column=0, columnspan=self.max_columnspan - 1, padx=self.xd, pady=self.yd) msg_w1 = "If this box is checked, a cobble_hsi raster is created in the SHArC/HSI/" + self.condition + "folder.\n" msg_w2 = "A wood.shp delineation shapefile (polygon) is needed in the 01_Conditions/" + self.condition + " folder.\n" self.b_h_wood = tk.Button( top, fg="RoyalBlue3", bg="white", text="Help", command=lambda: self.user_message(msg_w1 + msg_w2 + msg_0)) self.b_h_wood.grid(sticky=tk.EW, row=act_row, column=self.max_columnspan - 1, padx=self.xd, pady=self.yd) act_row += 1 # PLANTS ROW self.cb_veg = tk.Checkbutton( top, text="Make vegetation (plants) HSI raster", variable=self.plants, onvalue=True, offvalue=False, command=lambda: self.print_msg("Plants: " + str(self.plants.get()) )) self.cb_veg.grid(sticky=tk.W, row=act_row, column=0, columnspan=self.max_columnspan - 1, padx=self.xd, pady=self.yd) msg_v1 = "If this box is checked, a plants_hsi raster is created in the SHArC/HSI/" + self.condition + "folder.\n" msg_v2 = "A plants.shp delineation shapefile (polygon) is needed in the 01_Conditions/" + self.condition + " folder.\n" self.b_h_veg = tk.Button( top, fg="RoyalBlue3", bg="white", text="Help", command=lambda: self.user_message(msg_v1 + msg_v2 + msg_0)) self.b_h_veg.grid(sticky=tk.EW, row=act_row, column=self.max_columnspan - 1, padx=self.xd, pady=self.yd) act_row += 1 # RUN ROW self.b_run = tk.Button(top, bg="white", text="3) Run: Make cover HSI rasters", anchor='w', command=lambda: self.run_raster_calc()) self.b_run.grid(sticky=tk.EW, row=act_row, column=0, columnspan=self.max_columnspan, padx=self.xd, pady=self.yd) act_row += 1 # ROW LAST self.l_run_info = tk.Label(top, text="") self.l_run_info.grid(sticky=tk.W, row=act_row, column=0, columnspan=self.max_columnspan - 1, padx=self.xd, pady=self.yd) self.b_return = tk.Button(top, fg="RoyalBlue3", bg="white", text="RETURN to MAIN WINDOW", command=lambda: self.gui_quit()) self.b_return.grid(sticky=tk.E, row=act_row, column=1, columnspan=self.max_columnspan, padx=self.xd, pady=self.yd)
def __init__(self, from_master): sg.RaModuleGui.__init__(self, from_master) self.ww = 700 # window width self.wh = 490 # window height self.title = "Lifespan Design" self.set_geometry(self.ww, self.wh, self.title) self.condition_list = fGl.get_subdir_names(config.dir2conditions) self.condition_selected = False self.feature_list = [] self.features = cDef.FeatureDefinitions(False) self.habitat = False self.manning_n = 0.0473934 self.mapping = False self.out_lyt_dir = [] self.out_ras_dir = [] self.wild = False # GUI OBJECT VARIABLES self.gui_condition = tk.StringVar() self.gui_interpreter = tk.StringVar() self.extent_type = tk.StringVar() # LABELS self.l_s_feat = tk.Label(self, text="Selected features: ") self.l_s_feat.grid(sticky=tk.W, row=0, column=0, padx=self.xd, pady=self.yd) self.l_features = tk.Label( self, fg="red", text= "Choose from \'Add Features\' Menu (required for Raster Maker only)" ) self.l_features.grid(sticky=tk.W, row=0, column=1, columnspan=6, padx=self.xd, pady=self.yd) self.l_reach_label = tk.Label(self, text="Reaches:") self.l_reach_label.grid(sticky=tk.W, row=1, column=0, columnspan=1, padx=self.xd, pady=self.yd * 2) self.l_reaches = tk.Label( self, fg="red", text="Select from Reaches menu (required for Raster Maker only)") self.l_reaches.grid(sticky=tk.W, row=1, column=1, columnspan=6, padx=self.xd, pady=self.yd * 2) self.l_condition = tk.Label(self, text="Condition: \n") self.l_condition.grid(sticky=tk.W, row=3, column=0, columnspan=3, padx=self.xd, pady=self.yd) self.b_v_condition = tk.Button(self, fg="red", text="Select", command=lambda: self.select_condition()) self.b_v_condition.grid(sticky=tk.W, row=3, column=3, padx=self.xd, pady=self.yd) self.l_n = tk.Label(self, text="Roughness (Manning\'s n): %.3f " % self.manning_n) self.l_n.grid(sticky=tk.W, row=10, column=0, columnspan=3, padx=self.xd, pady=self.yd) # DROP DOWN ENTRIES (SCROLL BARS) self.sb_condition = tk.Scrollbar(self, orient=tk.VERTICAL) self.sb_condition.grid(sticky=tk.W, row=3, column=2, padx=0, pady=self.yd) self.lb_condition = tk.Listbox(self, height=3, width=14, yscrollcommand=self.sb_condition.set) for e in self.condition_list: self.lb_condition.insert(tk.END, e) self.lb_condition.grid(sticky=tk.W, row=3, column=1, padx=self.xd, pady=self.yd) self.sb_condition.config(command=self.lb_condition.yview) self.b_ref_condition = tk.Button( self, text="Refresh list", command=lambda: self.refresh_conditions( self.lb_condition, self.sb_condition, config.dir2conditions)) self.b_ref_condition.grid(sticky=tk.W, row=3, column=4, padx=self.xd, pady=self.yd) # BUTTONS self.b_mod_r = tk.Button( self, width=25, bg="white", text="Revise input file", command=lambda: self.open_inp_file("input_definitions.inp")) self.b_mod_r.grid(sticky=tk.EW, row=5, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.b_mod_r["state"] = "disabled" self.b_mod_m = tk.Button( self, width=25, bg="white", text="Modify map parameters", command=lambda: self.open_inp_file("mapping.inp")) self.b_mod_m.grid(sticky=tk.EW, row=5, column=2, columnspan=2, padx=self.xd, pady=self.yd) self.b_mod_th = tk.Button( self, width=25, bg="white", text="Modify survival threshold values", command=lambda: self.open_inp_file("threshold_values")) self.b_mod_th.grid(sticky=tk.EW, row=6, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.b_mod_rea = tk.Button(self, width=25, bg="white", text="Modify river/reach extents", command=lambda: self.open_inp_file( "computation_extents.xlsx", "MT")) self.b_mod_rea.grid(sticky=tk.EW, row=6, column=2, columnspan=2, padx=self.xd, pady=self.yd) self.b_n = tk.Button(self, width=25, bg="white", text="Change / Info", command=lambda: self.set_n()) self.b_n.grid(sticky=tk.W, row=10, column=2, columnspan=5, padx=self.xd, pady=self.yd) self.complete_menus() # CHECK BOXES(CHECKBUTTONS) self.cb_lyt = tk.Checkbutton( self, text="Include mapping after raster preparation", command=lambda: self.mod_mapping()) self.cb_lyt.grid(sticky=tk.W, row=7, column=0, columnspan=4, padx=self.xd, pady=self.yd) self.cb_wild = tk.Checkbutton( self, text="Apply wildcard raster to spatially confine analysis", command=lambda: self.mod_wild()) self.cb_wild.grid(sticky=tk.W, row=8, column=0, columnspan=5, padx=self.xd, pady=self.yd) self.cb_habitat = tk.Checkbutton(self, text="Apply habitat matching", command=lambda: self.mod_habitat()) self.cb_habitat.grid(sticky=tk.W, row=9, column=0, columnspan=5, padx=self.xd, pady=self.yd) self.cb_extent = tk.Checkbutton( self, text="Limit computation extent to boundary (boundary.tif) raster", variable=self.extent_type, onvalue="raster", offvalue="standard") self.cb_extent.grid(sticky=tk.W, row=11, column=0, columnspan=5, padx=self.xd, pady=self.yd) self.cb_extent.deselect()
def __init__(self, from_master): sg.RaModuleGui.__init__(self, from_master) self.ww = 570 # window width self.wh = 400 # window height self.title = "Max Lifespan" self.set_geometry(self.ww, self.wh, self.title) self.dir_base_ras = "None (Geofile Maker only)" self.dir2lf_rasters = config.dir2lf + "Output\\Rasters\\" self.feature_text = [] self.feature_type = [] self.condition = "set condition" self.condition_list = fGl.get_subdir_names(self.dir2lf_rasters) self.inpath = config.dir2lf + "Output\\Rasters\\" + str(self.condition) + "\\" self.mod_dir = False # if user-defined input directory: True # GUI OBJECT VARIABLES self.gui_condition = tk.StringVar() self.gui_interpreter = tk.StringVar() self.lf_extents = tk.BooleanVar() self.mapping = tk.BooleanVar() # LABELS self.l_s_feat = tk.Label(self, text="Selected feature layer: ") self.l_s_feat.grid(sticky=tk.W, row=0, column=0, padx=self.xd, pady=self.yd) self.l_features = tk.Label(self, width=40, fg="red", text="Select from \'Feature Layer\' Menu (Geofile Maker only)") self.l_features.grid(sticky=tk.W, row=0, column=1, columnspan=5, padx=self.xd, pady=self.yd) self.l_condition = tk.Label(self, text="Condition: \n(select)") self.l_condition.grid(sticky=tk.W, row=1, column=0, padx=self.xd, pady=self.yd) self.l_base_ras = tk.Label(self, text="Base raster: " + self.dir_base_ras) self.l_base_ras.grid(sticky=tk.W, row=6, column=0, columnspan=5, padx=self.xd, pady=self.yd) # DROP DOWN ENTRIES (SCROLL BARS) self.sb_condition = tk.Scrollbar(self, orient=tk.VERTICAL) self.sb_condition.grid(sticky=tk.W, row=1, column=2, padx=0, pady=self.yd) self.lb_condition = tk.Listbox(self, height=3, width=20, yscrollcommand=self.sb_condition.set) for e in self.condition_list: self.lb_condition.insert(tk.END, e) self.lb_condition.grid(sticky=tk.W, row=1, column=1, padx=self.xd, pady=self.yd) self.sb_condition.config(command=self.lb_condition.yview) self.b_ref_condition = tk.Button(self, text="Refresh list", command=lambda: self.refresh_conditions(self.lb_condition, self.sb_condition, config.dir2lf + "Output\\Rasters\\")) self.b_ref_condition.grid(sticky=tk.W, row=1, column=4, padx=self.xd, pady=self.yd) # ENTRIES self.l_inpath_curr = tk.Label(self, fg="dark slate gray", text="Source: "+str(self.dir2lf_rasters)) self.l_inpath_curr.grid(sticky=tk.W, row=3, column=0, columnspan=5, padx=self.xd, pady=self.yd) # BUTTONS self.b_c_help = tk.Button(self, width=5, bg="white", text="Info", command=lambda: self.condition_info()) self.b_c_help.grid(sticky=tk.W, row=1, column=3, padx=self.xd, pady=self.yd) self.b_inpath = tk.Button(self, width=50, bg="white", text="Change input directory", command=lambda: self.change_inpath()) self.b_inpath.grid(sticky=tk.W, row=2, column=0, columnspan=5, padx=self.xd, pady=self.yd) self.b_mod_m = tk.Button(self, width=50, bg="white", text="Modify map extent", command=lambda: self.open_inp_file("mapping.inp")) self.b_mod_m.grid(sticky=tk.W, row=7, column=0, columnspan=5, padx=self.xd, pady=self.yd) self.b_set_base = tk.Button(self, width=50, bg="white", text="Define extent Raster (FLOAT tif-raster)", command=lambda: self.set_base_ras()) self.b_set_base.grid(sticky=tk.W, row=5, column=0, columnspan=5, padx=self.xd, pady=self.yd) self.complete_menus() # CHECK BOXES (CHECKBUTTONS) self.cb_base = tk.Checkbutton(self, fg="SteelBlue", text="Use lifespan Raster extents OR", variable=self.lf_extents, onvalue=True, offvalue=False) self.cb_base.grid(sticky=tk.W, row=4, column=0, columnspan=5, padx=self.xd, pady=self.yd) self.cb_base.select() self.cb_lyt = tk.Checkbutton(self, fg="SteelBlue", text="Create maps and layouts after making geofiles", variable=self.mapping, onvalue=True, offvalue=False) self.cb_lyt.grid(sticky=tk.W, row=8, column=0, columnspan=5, padx=self.xd, pady=self.yd)
def list_habitat_conditions(self): # update habitat conditions listbox self.condition_list = fGl.get_subdir_names(self.dir_conditions) try: self.lb_condition_hy.delete(0, tk.END) self.lb_condition_cov.delete(0, tk.END) except: pass for e in self.condition_list: self.lb_condition_hy.insert(tk.END, e) self.lb_condition_cov.insert(tk.END, e) self.lb_condition_hy.grid(sticky=tk.E, row=4, column=2, padx=0, pady=self.yd) self.sb_condition_hy.config(command=self.lb_condition_hy.yview) self.lb_condition_cov.grid(sticky=tk.E, row=10, column=2, padx=0, pady=self.yd) self.sb_condition_cov.config(command=self.lb_condition_cov.yview) # update selection button try: self.b_c_select_hy.config( text="Confirm\nselection", command=lambda: self.select_HSIcondition("hy")) self.b_c_select_cov.config( text="Confirm\nselection", command=lambda: self.select_HSIcondition("cov")) except: self.b_c_select_hy = tk.Button( self, fg="cyan4", width=8, bg="white", text="Confirm\nselection", command=lambda: self.select_HSIcondition("hy")) self.b_c_select_cov = tk.Button( self, fg="gold4", width=8, bg="white", text="Confirm\nselection", command=lambda: self.select_HSIcondition("cov")) self.b_c_select_hy.grid(sticky=tk.W, row=4, rowspan=2, column=self.max_columnspan - 1, padx=self.xd, pady=self.yd) self.b_c_select_cov.grid(sticky=tk.W, row=10, rowspan=2, column=self.max_columnspan - 1, padx=self.xd, pady=self.yd) self.b_c_select_hy["state"] = "disabled" self.b_c_select_cov["state"] = "disabled"
def __init__(self, from_master): sg.RaModuleGui.__init__(self, from_master) self.ww = 580 # window width self.wh = 650 # window height self.title = "Stranding Risk" self.set_geometry(self.ww, self.wh, self.title) self.condition = "" self.out_dir = "" self.fish = cFi.Fish() self.fish_applied = {} row = 0 self.l_prompt = tk.Label(self, text="Select Condition and Physical Habitat") self.l_prompt.grid(sticky=tk.W, row=row, column=0, columnspan=3, padx=self.xd, pady=self.yd) row += 1 # select condition self.l_condition = tk.Label(self, text="Select condition:") self.l_condition.grid(sticky=tk.W, row=row, column=0, padx=self.xd, pady=self.yd) self.combo_c = ttk.Combobox(self) self.combo_c.grid(sticky=tk.W, row=row, column=1, padx=self.xd, pady=self.yd) self.combo_c['values'] = tuple( fGl.get_subdir_names(config.dir2conditions)) self.combo_c['state'] = 'readonly' self.b_s_condition = tk.Button(self, fg="red", text="Select", command=lambda: self.select_condition()) self.b_s_condition.grid(sticky=tk.W, row=row, column=2, columnspan=2, padx=self.xd, pady=self.yd) row += 1 self.l_inpath_curr = tk.Label(self, fg="gray60", text="Source: " + config.dir2conditions) self.l_inpath_curr.grid(sticky=tk.W, row=row, column=0, columnspan=3, padx=self.xd, pady=self.yd) row += 1 # select Physical Habitat self.b_show_fish = tk.Button( self, width=10, fg="RoyalBlue3", bg="white", text="Show selected Physical Habitat(s)", command=lambda: self.shout_dict(self.fish_applied)) self.b_show_fish.grid(sticky=tk.EW, row=row, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.b_show_fish["state"] = "disabled" self.l_aqua = tk.Label(self, fg="red", text="Select Physical Habitat (at least one)") self.l_aqua.grid(sticky=tk.W, row=row, column=2, columnspan=2, padx=0, pady=self.yd) row += 1 # Apply flow reduction tk.Label(self, text=" ").grid(row=row, column=0, columnspan=4) # dummy row += 1 tk.Label(self, text="", bg="LightBlue1", height=10).grid(sticky=tk.EW, row=row, rowspan=4, column=0, columnspan=4) # dummy self.l_flow_red = tk.Label(self, text="Apply flow reduction", bg="LightBlue1") self.l_flow_red.grid(sticky=tk.W, row=row, column=0, columnspan=4, padx=self.xd, pady=self.yd) row += 1 self.l_q_high = tk.Label(self, text="Q_high:", bg="LightBlue1") self.l_q_high.grid(sticky=tk.W, row=row, column=0, padx=self.xd, pady=self.yd) self.c_q_high = ttk.Combobox(self) self.c_q_high.grid(sticky=tk.W, row=row, column=1, padx=self.xd, pady=self.yd) self.c_q_high['state'] = 'disabled' self.l_q_low = tk.Label(self, text="Q_low:", bg="LightBlue1") self.l_q_low.grid(sticky=tk.W, row=row, column=2, padx=self.xd, pady=self.yd) self.c_q_low = ttk.Combobox(self) self.c_q_low.grid(sticky=tk.W, row=row, column=3, padx=self.xd, pady=self.yd) self.c_q_low['state'] = 'disabled' row += 1 self.l_dt = tk.Label(self, text="Time period (mins):", bg="LightBlue1") self.l_dt.grid(sticky=tk.W, row=row, column=0, padx=self.xd, pady=self.yd) self.e_dt = tk.Entry(self) self.e_dt.grid(sticky=tk.W, row=row, column=1, padx=self.xd, pady=self.yd) self.l_interp = tk.Label(self, text="Interpolation method:", bg="LightBlue1") self.l_interp.grid(sticky=tk.W, row=row, column=2, padx=self.xd, pady=self.yd) self.c_interp = ttk.Combobox(self) self.c_interp.grid(sticky=tk.W, row=row, column=3, padx=self.xd, pady=self.yd) self.c_interp['state'] = 'readonly' self.c_interp['values'] = ["IDW", "EBK", "Kriging", "Nearest Neighbor"] self.c_interp.set("IDW") row += 1 self.b_apply_flow_red = tk.Button( self, text="Apply Flow Reduction", bg="LightBlue1", width=50, command=lambda: self.apply_flow_red()) self.b_apply_flow_red.grid(sticky=tk.W, row=row, column=0, columnspan=4, padx=self.xd, pady=self.yd) self.b_apply_flow_red['state'] = 'disabled' self.complete_menus()
def __init__(self, from_master): sg.RaModuleGui.__init__(self, from_master) self.ww = 800 # window width self.wh = 840 # window height self.title = "SHArC" self.set_geometry(self.ww, self.wh, self.title) self.bound_shp = "" # full path of a boundary shapefile self.combine_method = "geometric_mean" self.dir_conditions = config.dir2sh + "HSI\\" self.dir_inp_hsi_hy = "" self.dir_inp_hsi_cov = "" self.chsi_condition_hy = "" self.chsi_condition_cov = "" self.condition_list = fGl.get_subdir_names(self.dir_conditions) self.cover_applies = False self.fish = cFi.Fish() self.fish_applied = {} self.max_columnspan = 5 self.sharea_threshold = 0.5 self.side_pnl_width = 15 self.xlsx_condition = [] self.apply_boundary = tk.BooleanVar() self.apply_wua = tk.BooleanVar() self.external_flow_series = tk.BooleanVar() self.cover_applies_sharea = tk.BooleanVar() # LABELS self.l_side_bar = tk.Label(self, text="", bg="white", height=55, width=self.side_pnl_width + self.xd) self.l_side_bar.grid(sticky=tk.W, row=0, rowspan=30, column=self.max_columnspan, padx=self.xd, pady=self.yd) self.l_aqua = tk.Label(self, fg="firebrick3", text="Select Physical Habitat (at least one)") self.l_aqua.grid(sticky=tk.W, row=0, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.l_combine = tk.Label(self, text="Select HSI combination method: ") self.l_combine.grid(sticky=tk.W, row=2, column=0, columnspan=1, padx=self.xd, pady=self.yd) tk.Label(self, text="").grid(sticky=tk.W, row=3, column=0) # dummy imsg = "\n(Use \'Make HSI Rasters\' menu to create habitat conditions)" self.l_condition_hy = tk.Label( self, justify=tk.LEFT, fg="cyan4", text="Hydraulic habitat conditions (no cover):" + imsg) self.l_condition_hy.grid(sticky=tk.W, row=4, rowspan=3, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.l_inpath_hy = tk.Label(self, justify=tk.LEFT, fg="cyan4", text="Source: " + str(self.dir_conditions)) self.l_inpath_hy.grid(sticky=tk.W, row=7, column=0, columnspan=self.max_columnspan + 1, padx=self.xd, pady=self.yd) tk.Label(self, text="").grid(sticky=tk.W, row=9, column=0) # dummy self.l_condition_hy["state"] = "disabled" self.l_inpath_hy["state"] = "disabled" self.l_condition_cov = tk.Label(self, justify=tk.LEFT, fg="gold4", text="Cover habitat conditions:" + imsg) self.l_condition_cov.grid(sticky=tk.W, row=10, rowspan=3, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.l_inpath_cov = tk.Label(self, justify=tk.LEFT, fg="gold4", text="Source: " + str(self.dir_conditions)) self.l_inpath_cov.grid(sticky=tk.W, row=13, column=0, columnspan=self.max_columnspan + 1, padx=self.xd, pady=self.yd) tk.Label(self, text="").grid(sticky=tk.W, row=15, column=0) # dummy self.l_condition_cov["state"] = "disabled" self.l_inpath_cov["state"] = "disabled" # DROP DOWN ENTRIES (SCROLL BARS) self.sb_condition_hy = tk.Scrollbar(self, orient=tk.VERTICAL) self.sb_condition_hy.grid(sticky=tk.W, row=4, column=3, padx=0, pady=self.yd) self.lb_condition_hy = tk.Listbox( self, height=3, width=15, yscrollcommand=self.sb_condition_hy.set) self.sb_condition_cov = tk.Scrollbar(self, orient=tk.VERTICAL) self.sb_condition_cov.grid(sticky=tk.W, row=10, column=3, padx=0, pady=self.yd) self.lb_condition_cov = tk.Listbox( self, height=3, width=15, yscrollcommand=self.sb_condition_cov.set) self.list_habitat_conditions() # CHECK BUTTONS -- determine if geometric mean or product is used self.cb_combine_method_gm = tk.Checkbutton( self, text="Geometric mean", variable=self.combine_method, onvalue="geometric_mean", offvalue="product") self.cb_combine_method_gm.grid(sticky=tk.W, row=2, column=2, padx=self.xd, pady=self.yd) self.cb_combine_method_gm.select() self.cb_combine_method_pd = tk.Checkbutton( self, text="Product", variable=self.combine_method, onvalue="product", offvalue="geometric_mean") self.cb_combine_method_pd.grid(sticky=tk.W, row=2, column=3, columnspan=2, padx=self.xd, pady=self.yd) self.cb_bshp = tk.Checkbutton( self, text="Use calculation boundary (polygon) shapefile", variable=self.apply_boundary, onvalue=True, offvalue=False, command=lambda: self.activate_shape_selection(self.b_select_bshp)) self.cb_bshp.grid(sticky=tk.W, row=1, column=0, columnspan=self.max_columnspan - 1, padx=self.xd, pady=self.yd) self.cb_use_cov = tk.Checkbutton( self, fg="gold4", text="Use cover CHSI (requires COVER HSI conditions)", variable=self.cover_applies_sharea, onvalue=True, offvalue=False) self.cb_use_cov.grid(sticky=tk.W, row=16, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.cb_use_cov["state"] = "disabled" # self.cb_use_wua = tk.Checkbutton(self, fg="gold4", text="Use weighted usable area", # variable=self.apply_wua, # onvalue=True, offvalue=False, command=lambda: self.set_wua()) # self.cb_use_wua.grid(sticky=tk.W, row=16, column=3, columnspan=2, padx=self.xd, # pady=self.yd) # self.cb_use_wua["state"] = "disabled" # BUTTONS self.b_show_fish = tk.Button( self, width=self.side_pnl_width, fg="RoyalBlue3", bg="white", text="Show selected\nPhysical Habitat(s)", command=lambda: self.shout_dict(self.fish_applied)) self.b_show_fish.grid(sticky=tk.EW, row=0, rowspan=2, column=self.max_columnspan, padx=self.xd, pady=self.yd) self.b_show_fish["state"] = "disabled" self.b_select_bshp = tk.Button( self, width=8, bg="white", text="Select file", command=lambda: self.select_boundary_shp()) self.b_select_bshp.grid(sticky=tk.W, row=1, column=self.max_columnspan - 1, padx=self.xd, pady=self.yd) self.b_select_bshp["state"] = "disabled" self.b_csi_nc = tk.Button( self, fg="cyan4", width=30, bg="white", text="Combine HSI rasters (pure hydraulic)", command=lambda: self.start_app("cHSI", cover=False)) self.b_csi_nc.grid(sticky=tk.EW, row=8, column=0, columnspan=self.max_columnspan, padx=self.xd, pady=self.yd) self.b_csi_nc["state"] = "disabled" self.b_csi_c = tk.Button( self, fg="gold4", width=30, bg="white", text="Combine HSI rasters (hydraulic and cover)", command=lambda: self.start_app("cHSI", cover=True)) self.b_csi_c.grid(sticky=tk.EW, row=14, column=0, columnspan=self.max_columnspan, padx=self.xd, pady=self.yd) self.b_csi_c["state"] = "disabled" self.b_sharc = tk.Button( self, width=30, bg="white", text="Run Seasonal Habitat Area Calculator - SHArC", command=lambda: self.start_app("sharea", cover=False)) self.b_sharc.grid(sticky=tk.EW, row=17, column=0, columnspan=self.max_columnspan, rowspan=2, padx=self.xd, pady=self.yd) self.b_sharc["state"] = "disabled" self.b_sha_th = tk.Button( self, width=self.side_pnl_width, fg="RoyalBlue3", bg="white", text="Set SHArea\nthreshold\nCurrent: CHSI = " + str(self.sharea_threshold), command=lambda: self.set_sharea()) self.b_sha_th.grid(sticky=tk.EW, row=16, rowspan=4, column=self.max_columnspan, padx=self.xd, pady=self.yd) self.b_sha_th["state"] = "disabled" # Q-UA analyses section tk.Label(self, text="").grid(sticky=tk.W, row=18, column=0, columnspan=self.max_columnspan) # dummy tk.Label(self, text="", bg="LightBlue1", height=10).grid(sticky=tk.EW, row=19, rowspan=6, column=0, columnspan=self.max_columnspan) # dummy self.l_qua = tk.Label(self, text="Q - Area Analysis", bg="LightBlue1") self.l_qua.grid(sticky=tk.NW, row=19, column=0, columnspan=self.max_columnspan, padx=self.xd, pady=self.yd) self.cb_extq = tk.Checkbutton(self, text="Use other flow duration curve", variable=self.external_flow_series, onvalue=True, offvalue=False, bg="LightBlue1") self.cb_extq.grid(sticky=tk.W, row=20, column=0, columnspan=self.max_columnspan, padx=self.xd, pady=self.yd) self.cb_extq.deselect() self.b_qua = tk.Button( self, bg="LightBlue1", text="Discharge - Physical Habitat Area Curve", command=lambda: self.make_qua(input_type="statistic")) self.b_qua.grid(sticky=tk.EW, row=21, column=0, columnspan=1, padx=self.xd, pady=self.yd) self.b_quat = tk.Button( self, bg="LightBlue1", text="Time series - Physical Habitat Area", command=lambda: self.make_qua(input_type="time_series")) self.b_quat.grid(sticky=tk.EW, row=21, column=2, columnspan=2, padx=self.xd, pady=self.yd) self.b_qua["state"] = "disabled" self.b_quat["state"] = "disabled" self.complete_menus()
def __init__(self, master): top = self.top = tk.Toplevel(master) self.condition_list = fGl.get_subdir_names(config.dir2conditions) self.dir2dem = '' self.dir2h = '' self.dir2u = '' self.flows_xlsx = '' # define analysis type identifiers (default = False) self.bool_var = tk.BooleanVar() self.top.iconbitmap(config.code_icon) # ARRANGE GEOMETRY # width and height of the window. ww = 400 wh = 200 self.xd = 5 # distance holder in x-direction (pixel) self.yd = 5 # distance holder in y-direction (pixel) # height and location wx = (self.top.winfo_screenwidth() - ww) / 2 wy = (self.top.winfo_screenheight() - wh) / 2 self.top.geometry("%dx%d+%d+%d" % (ww, wh, wx, wy)) self.top.title("Make Input File") # window title self.col_0_width = 25 # Set Condition self.l_info = tk.Label( top, text= "Make sure to Analyze Flows before creating an input_definitions.inp file." ) self.l_info.grid(sticky=tk.W, row=0, column=0, columnspan=3, padx=self.xd, pady=self.yd) self.l_name = tk.Label(top, text="Select condition: ") self.l_name.grid(sticky=tk.W, row=1, rowspan=3, column=0, padx=self.xd, pady=self.yd) self.sb_condition = tk.Scrollbar(top, orient=tk.VERTICAL) self.sb_condition.grid(sticky=tk.W, row=1, column=2, padx=0, pady=self.yd) self.lb_condition = tk.Listbox(top, height=3, width=15, yscrollcommand=self.sb_condition.set) for ce in self.condition_list: self.lb_condition.insert(tk.END, ce) self.lb_condition.grid(sticky=tk.EW, row=1, column=1, padx=0, pady=self.yd) self.sb_condition.config(command=self.lb_condition.yview) self.b_sc = tk.Button(top, width=self.col_0_width - 5, fg="firebrick3", bg="white", text="Generate file", command=lambda: self.make_input_file()) self.b_sc.grid(sticky=tk.E, row=1, rowspan=3, column=2, padx=self.xd, pady=self.yd) self.l_c_dir = tk.Label(top, fg="firebrick3", text="Make input definition (.inp) file.") self.l_c_dir.grid(sticky=tk.W, row=4, column=0, columnspan=4, padx=self.xd, pady=self.yd) tk.Label(top, text="").grid(sticky=tk.W, row=5, column=0) # dummy self.b_return = tk.Button(top, width=self.col_0_width, fg="RoyalBlue3", bg="white", text="RETURN to MAIN WINDOW", command=lambda: self.gui_quit()) self.b_return.grid(sticky=tk.E, row=6, column=2, padx=self.xd, pady=self.yd)