我们从Python开源项目中,提取了以下25个代码示例,用于说明如何使用ipywidgets.HBox()。
def create_navigator_1d(self): import ipywidgets as ipyw x_min, x_max = 0, self.signal.axes_manager.navigation_size - 1 x_text = ipyw.BoundedIntText(value=self.indices[0], description="Coordinate", min=x_min, max=x_max, layout=ipyw.Layout(flex='0 1 auto', width='auto')) randomize = ipyw.Button(description="Randomize", layout=ipyw.Layout(flex='0 1 auto', width='auto')) container = ipyw.HBox((x_text, randomize)) def on_index_change(change): self.indices = (x_text.value,) self.replot_image() def on_randomize(change): from random import randint x = randint(x_min, x_max) x_text.value = x x_text.observe(on_index_change, names='value') randomize.on_click(on_randomize) return container
def idisplay(*args, label=True): """Display multiple values using ipywidget HBox Arguments: * `*args` -- list of values Keyword arguments: * `label` -- create a Label widget instead of a Text widget, if value is not a widget """ new_widget = lambda x: Label(x) if label else Text(value=x) args = [ arg if isinstance(arg, DOMWidget) else new_widget(arg) for arg in args ] display(HBox(args))
def download_mutation_images(self): # TODO: dunno if this works import ipywidgets import math views = [] for g in self.reference_gempro.genes: if g.protein.representative_structure: view = g.protein.view_all_mutations(alignment_type='seqalign', grouped=False, structure_opacity=0.5, opacity_range=(0.6, 1), scale_range=(.5, 5)) view._remote_call("setSize", target='Widget', args=['300px', '300px']) view.download_image(filename='{}_{}_mutations.png'.format(g.id, g.name)) views.append(view) hboxes = [ipywidgets.HBox(views[i * 3:i * 3 + 3]) for i in range(int(math.ceil(len(views) / 3.0)))] vbox = ipywidgets.VBox(hboxes) return vbox
def __init__(self, training_length=None, update_interval=100, bar_length=50): self._training_length = training_length if training_length is not None: self._init_status_template() self._update_interval = update_interval self._recent_timing = [] self._total_bar = FloatProgress(description='total', min=0, max=1, value=0, bar_style='info') self._total_html = HTML() self._epoch_bar = FloatProgress(description='this epoch', min=0, max=1, value=0, bar_style='info') self._epoch_html = HTML() self._status_html = HTML() self._widget = VBox([HBox([self._total_bar, self._total_html]), HBox([self._epoch_bar, self._epoch_html]), self._status_html])
def define_site_description_time_series(self): '''Widgets for site description parameters''' self.w_lat = widgets.BoundedFloatText( value=self.lat, min=-90, max=90, description='Lat.', width=100) self.w_lon = widgets.BoundedFloatText( value=self.lon, min=-180, max=180, description='Lon.', width=100) self.w_alt = widgets.FloatText( value=self.alt, description='Alt.', width=100) self.w_stdlon = widgets.BoundedFloatText( value=self.stdlon, min=-180, max=180, description='Std. Lon.', width=100) self.w_z_u = widgets.BoundedFloatText( value=self.zu, min=0.001, description='Wind meas. height', width=100) self.w_z_T = widgets.BoundedFloatText( value=self.zt, min=0.001, description='T meas. height', width=100) self.site_page = widgets.VBox([widgets.HBox([self.w_lat, self.w_lon, self.w_alt, self.w_stdlon]), widgets.HBox([self.w_z_u, self.w_z_T])], background_color='#EEE')
def spectral_properties_time_series(self): '''Widgets for site spectral properties''' self.w_rho_vis_C = widgets.BoundedFloatText( value=self.rho_vis_C, min=0, max=1, description='Leaf refl. PAR', width=80) self.w_tau_vis_C = widgets.BoundedFloatText( value=self.tau_vis_C, min=0, max=1, description='Leaf trans. PAR', width=80) self.w_rho_nir_C = widgets.BoundedFloatText( value=self.rho_nir_C, min=0, max=1, description='Leaf refl. NIR', width=80) self.w_tau_nir_C = widgets.BoundedFloatText( value=self.tau_nir_C, min=0, max=1, description='Leaf trans. NIR', width=80) self.w_rho_vis_S = widgets.BoundedFloatText( value=self.rho_vis_S, min=0, max=1, description='Soil refl. PAR', width=80) self.w_rho_nir_S = widgets.BoundedFloatText( value=self.rho_nir_S, min=0, max=1, description='Soil refl. NIR', width=80) self.w_emis_C = widgets.BoundedFloatText( value=self.emis_C, min=0, max=1, description='Leaf emissivity', width=80) self.w_emis_S = widgets.BoundedFloatText( value=self.emis_S, min=0, max=1, description='Soil emissivity', width=80) self.spec_page = widgets.VBox([widgets.HBox([self.w_rho_vis_C, self.w_tau_vis_C, self.w_rho_nir_C, self.w_tau_nir_C]), widgets.HBox( [self.w_rho_vis_S, self.w_rho_nir_S, self.w_emis_C, self.w_emis_S])], background_color='#EEE')
def create_navigator_2d(self): import ipywidgets as ipyw x_min, y_min = 0, 0 x_max, y_max = self.signal.axes_manager.navigation_shape x_max -= 1 y_max -= 1 x_text = ipyw.BoundedIntText(value=self.indices[0], description="x", min=x_min, max=x_max, layout=ipyw.Layout(flex='0 1 auto', width='auto')) y_text = ipyw.BoundedIntText(value=self.indices[1], description="y", min=y_min, max=y_max, layout=ipyw.Layout(flex='0 1 auto', width='auto')) randomize = ipyw.Button(description="Randomize", layout=ipyw.Layout(flex='0 1 auto', width='auto')) container = ipyw.HBox((x_text, y_text, randomize)) def on_index_change(change): self.indices = (x_text.value, y_text.value) self.replot_image() def on_randomize(change): from random import randint x = randint(x_min, x_max) y = randint(y_min, y_max) x_text.value = x y_text.value = y x_text.observe(on_index_change, names='value') y_text.observe(on_index_change, names='value') randomize.on_click(on_randomize) return container
def drawGUI(): ''' Draw the GUI on the screen ''' display(widget_dict['aws_id_widget']) display(widget_dict['aws_secret_widget']) display(widget_dict['aws_region_widget']) display(widget_dict['aws_security_widget']) display(widget_dict['aws_keyname_widget']) display(widget_dict['aws_pem_widget']) display(widget_dict['aws_image_id']) display(widget_dict['instance_type_widget']) display(widgets.HBox([widget_dict['initialize_button'], widget_dict['cache_button'],widget_dict['restore_button']])) # display(widgets.HBox([widget_dict['label_num_instances'], widget_dict['new_num_instances_widget']])) # display(widgets.HBox([widget_dict['run_label'], widget_dict['aws_status_widget']])) display(widget_dict['new_num_instances_widget']) display(widget_dict['aws_status_widget']) display(widget_dict['execute_instances_button'])
def __init__(self, initial_value='', default=''): if initial_value == '': try: initial_value = iris.sample_data_path('') except ValueError: initial_value = '' # Define the file system path for input files. self._path = ipywidgets.Text( description='Path:', value=initial_value, width="100%") # Observe the path. self._path.observe(self._handle_path, names='value') # Use default path value to initialise file options. options = [] if os.path.exists(self._path.value): options = glob.glob('{}/*'.format(self._path.value)) options.sort() default_list = [] for default_value in default.split(','): if default_value in options: default_list.append(default_value) default_tuple = tuple(default_list) # Defines the files selected to be loaded. self._files = ipywidgets.SelectMultiple( description='Files:', options=OrderedDict([(os.path.basename(f), f) for f in options]), value=default_tuple, width="100%" ) self.deleter = ipywidgets.Button(description='delete tab', height='32px', width='75px') hbox = ipywidgets.HBox(children=[self._files, self.deleter]) self._box = ipywidgets.Box(children=[self._path, hbox], width="100%")
def _create_shelf(self, i=0): """ Creates shelf to plot a dimension (includes buttons for data column, encoding, data type, aggregate) """ encodings = _get_encodings() cols = widgets.Dropdown(options=self.columns, description='encode') encoding = widgets.Dropdown(options=encodings, description='as', value=encodings[i]) encoding.layout.width = '20%' adv = widgets.VBox(children=[], visible=False) button = widgets.Button(description='options') button.on_click(self._show_advanced) button.layout.width = '10%' # The callbacks when the button is clicked encoding.observe(self._update, names='value') cols.observe(self._update, names='value') # Making sure we know what row we're in in the callbacks encoding.row = cols.row = button.row = adv.row = i # Have the titles so we know what button we're editing encoding.title = 'encoding' cols.title = 'field' button.title = 'button' adv.title = 'advanced' return widgets.HBox([cols, encoding, button, adv])
def _generate_controller(self, ndims): marks = _get_marks() # mark button mark_choose = widgets.Dropdown(options=marks, description='Marks') mark_choose.observe(self._update, names='value') mark_choose.layout.width = '20%' mark_choose.row = -1 mark_choose.title = 'mark' # mark options button mark_but = widgets.Button(description='options') mark_but.layout.width = '10%' mark_but.row = -1 mark_but.title = 'mark_button' # Mark options mark_opt = widgets.VBox(children=[], visible=False) mark_but.on_click(self._show_advanced) mark_opt.title = 'mark_options' mark_opt.layout.width = '300px' add_dim = widgets.Button(description='add encoding') add_dim.on_click(self._add_dim) to_altair = widgets.Button(description='chart.to_altair()') to_altair.on_click(self._to_altair) dims = [self._create_shelf(i=i) for i in range(ndims)] choices = dims + [widgets.HBox([add_dim, to_altair, mark_choose, mark_but, mark_opt])] return widgets.VBox(choices)
def additional_options_point(self): '''Widgets for additional TSEB options''' self.calc_G_options() self.opt_page = widgets.VBox([ self.w_G_form, self.w_Gratio, self.w_Gconstanttext, self.w_Gconstant, widgets.HBox([self.w_G_amp, self.w_G_phase, self.w_G_shape])], background_color='#EEE')
def create_navigator(self): from ipywidgets import HBox container = HBox() if self.signal.axes_manager.navigation_dimension == 2: container = self.create_navigator_2d() elif self.signal.axes_manager.navigation_dimension == 1: container = self.create_navigator_1d() display(container)
def __call__(self, parameterized, **params): self.p = param.ParamOverrides(self, params) if self.p.initializer: self.p.initializer(parameterized) self._widgets = {} self.parameterized = parameterized widgets, views = self.widgets() layout = ipywidgets.Layout(display='flex', flex_flow=self.p.layout) if self.p.close_button: layout.border = 'solid 1px' widget_box = ipywidgets.VBox(children=widgets, layout=layout) if views: view_box = ipywidgets.VBox(children=views, layout=layout) layout = self.p.view_position if layout in ['below', 'right']: children = [widget_box, view_box] else: children = [view_box, widget_box] box = ipywidgets.VBox if layout in ['below', 'above'] else ipywidgets.HBox widget_box = box(children=children) display(Javascript(WIDGET_JS)) display(widget_box) self._widget_box = widget_box for view in views: p_obj = self.parameterized.params(view.name) value = getattr(self.parameterized, view.name) if value is not None: self._update_trait(view.name, p_obj.renderer(value)) # Keeps track of changes between button presses self._changed = {} if self.p.on_init: self.execute()
def interactive(img, cmap='gray', window=(2, 98)): import ipywidgets as ipy # Get some information about the image bbox = Box.fromMask(img) window_vals = np.nanpercentile(img.get_data(), window) # Setup figure fig, axes = plt.subplots(1, 3, figsize=(8, 4)) implots = [None, None, None] for i in range(3): sl = Slice(bbox, bbox.center, i, 256, orient='clin') sl_img = sl.sample(img, order=0) sl_color = colorize(sl_img, cmap, window_vals) implots[i] = axes[i].imshow(sl_color, origin='lower', extent=sl.extent, cmap=cmap, vmin = 0.1) axes[i].axis('off') def wrap_sections(x, y, z): for i in range(3): sl = Slice(bbox, np.array((x, y, z)), i, 256, orient='clin') sl_img = sl.sample(img, order=0) sl_color = colorize(sl_img, cmap, window_vals) implots[i].set_data(sl_color) plt.show() # Setup widgets slider_x = ipy.FloatSlider(min=bbox.start[0], max=bbox.end[0], value=bbox.center[0]) slider_y = ipy.FloatSlider(min=bbox.start[1], max=bbox.end[1], value=bbox.center[1]) slider_z = ipy.FloatSlider(min=bbox.start[2], max=bbox.end[2], value=bbox.center[2]) widgets = ipy.interactive(wrap_sections, x=slider_x, y=slider_y, z=slider_z) # Now do some manual layout hbox = ipy.HBox(widgets.children[0:3]) # Set the sliders to horizontal layout vbox = ipy.VBox((hbox, widgets.children[3])) # iplot.widget.children[-1].layout.height = '350px' return vbox
def __init__(self, mode="text"): self.mode_widget = Dropdown( options={ 'BibTeX': 'bibtex', 'Text': 'text', '[N] author name place other year': 'citation', 'Quoted': 'quoted', }, value=mode ) self.button_widget = Button( description="Set article_list variable", disabled=mode not in ("citation", "bibtex") ) self.frompdf_widget = Textarea() self.output_widget = Textarea() self.label_widget = Label() self.frompdf_widget.observe(self.write) self.mode_widget.observe(self.select) self.button_widget.on_click(self.set_variable) self.view = VBox([ HBox([self.mode_widget, self.button_widget, self.label_widget]), HBox([self.frompdf_widget, self.output_widget]) ]) self.frompdf_widget.layout.height = "500px" self.output_widget.layout.height = "500px" self.frompdf_widget.layout.width = "50%" self.output_widget.layout.width = "50%" self.backup = "" self.ipython = get_ipython()
def __init__(self, querier, citation_var, citation_file=None, debug=False, start=None, load=True): from .selenium_scholar import URLQuery reload() self.querier = querier work = work_by_varname(citation_var) citation_file = citation_file or getattr(work, "citation_file", citation_var) self.navigator = ArticleNavigator(citation_var, citation_file, backward=False, force_citation_file=False) self.query = URLQuery(self.navigator.work.scholar, start) self.next_page_widget = Button(description='Next Page', icon='fa-arrow-right') self.reload_widget = Button(description='Reload', icon='fa-refresh') self.previous_page_widget = Button(description='Previous Page', icon='fa-arrow-left') self.debug_widget = ToggleButton(value=debug, description="Debug") self.page_number_widget = Label(value="") self.next_page_widget.on_click(self.next_page) self.reload_widget.on_click(self.reload) self.previous_page_widget.on_click(self.previous_page) self.view = Tab([ VBox([ HBox([ self.previous_page_widget, self.reload_widget, self.next_page_widget, self.debug_widget, self.page_number_widget ]), self.navigator.output_widget, ]), self.navigator.view ]) self.view.set_title(0, "Page") self.view.set_title(1, "Article") if load: self.reload(None)
def __init__(self, querier, worklist, force=False, debug=False, index=0): reload() self.worklist = worklist self.force = force self.querier = querier self.next_page_widget = Button(description='Next Work', icon='fa-arrow-right') self.reload_widget = Button(description='Reload', icon='fa-refresh') self.previous_page_widget = Button(description='Previous Work', icon='fa-arrow-left') self.debug_widget = ToggleButton(value=debug, description="Debug") self.textarea_widget = ToggleButton(value=False, description="TextArea") self.page_number_widget = Label(value="") self.output_widget = Output() self.next_page_widget.on_click(self.next_page) self.reload_widget.on_click(self.reload) self.previous_page_widget.on_click(self.previous_page) self.textarea_widget.observe(self.show) self.view = VBox([ HBox([ self.previous_page_widget, self.reload_widget, self.next_page_widget, self.debug_widget, self.textarea_widget, self.page_number_widget ]), self.output_widget ]) self.index = index self.varname = "" self.work = None self.articles = [] self.reload(show=False)
def show_bars(self): self._pbar = ipywidgets.IntProgress() self._pbar_desc = ipywidgets.HTML(value=self._status_initial) self._pbar_total = ipywidgets.IntProgress() self._pbar_total_desc = ipywidgets.HTML(value=self._status_initial) display(ipywidgets.VBox([ipywidgets.HBox([self._pbar_total, self._pbar_total_desc]), ipywidgets.HBox([self._pbar, self._pbar_desc])]))
def __init__(self, url=''): self.file_pickers = [] if url: o = urlparse(url) query = parse_qs(o.query) pwd, = query.get('pwd', ['']) for fname in query.get('files', []): self.file_pickers.append(FilePicker(pwd, os.path.join(pwd, fname))) for fpath in query.get('folders', []): self.file_pickers.append(FilePicker(fpath)) if not self.file_pickers: self.file_pickers.append(FilePicker()) # Define load action. self._load_button = ipywidgets.Button(description="load these files") self._load_button.on_click(self._handle_load) self._file_tab_button = ipywidgets.Button(description="add tab") self._file_tab_button.on_click(self._handle_new_tab) self._subplots = ipywidgets.RadioButtons(description='subplots', options=[1, 2]) self._subplots.observe(self._handle_nplots, names='value') # Plot action button. self._plot_button = ipywidgets.Button(description="Plot my cube") self._plot_button.on_click(self._goplot) # Configure layout of the Explorer. self._plot_container = ipywidgets.Box() # Define a Tab container for the main controls in the browse interface. children = [fp.box for fp in self.file_pickers] self.ftabs = ipywidgets.Tab(children=children) children = [self._load_button, self._file_tab_button] self.bbox = ipywidgets.HBox(children=children) children = [self.ftabs, self.bbox] self._file_picker_tabs = ipywidgets.Box(children=children) # Define the plot controls, start with 1 (self._subplots default) self.plot_controls = [PlotControl()] pcc_children = [pc.box for pc in self.plot_controls] self._plot_control_container = ipywidgets.Tab(children=pcc_children) self._plot_control_container.set_title(0, 'Plot Axes 0') # Define an Accordian for files, subplots and plots acc_children = [self._file_picker_tabs, self._subplots, self._plot_control_container] self._accord = ipywidgets.Accordion(children=acc_children) self._accord.set_title(0, 'Files') self._accord.set_title(1, 'SubPlots') self._accord.set_title(2, 'Plots') # Initialise cubes container self._cubes = [] # Display the browse interface. IPython.display.display(self._accord) IPython.display.display(self._plot_button) IPython.display.display(self._plot_container)
def __init__(self, plots): """ Compiles non-axis coordinates into sliders, the values from which are used to reconstruct plots upon movement of slider. Args: * plot cube_browser plot instance to display with slider. """ if not isinstance(plots, Iterable): plots = [plots] self.plots = plots # Mapping of coordinate/alias name to axis. self._axis_by_name = {} # Mapping of cube-id to shared cache. self._cache_by_cube_id = {} # Mapping of plot-id to coordinate/alias name. self._names_by_plot_id = {} # Mapping of coordinate/alias name to plots. self._plots_by_name = {} self._build_mappings() self._slider_by_name = {} self._name_by_slider_id = {} if self._axis_by_name: name_len = max([len(name) for name in self._axis_by_name]) children = [] for axis in self._axis_by_name.values(): if hasattr(axis, 'coord') and axis.coord.units.is_time_reference(): pairs = [(axis.coord.units.num2date(axis.coord.points[i]), i) for i in range(axis.size)] elif hasattr(axis, 'coord'): pairs = [(axis.coord.points[i], i) for i in range(axis.size)] else: pairs = [(i, i) for i in range(axis.size)] options = OrderedDict(pairs) slider = ipywidgets.SelectionSlider(options=options) slider.observe(self.on_change, names='value') self._slider_by_name[axis.name] = slider self._name_by_slider_id[id(slider)] = axis.name # Explicitly control the slider label in order to avoid # fix width widget description label wrapping issues. # XXX: Adjust px/em scale-factor dynamically based on font-size. scale_factor = .65 width = u'{}em'.format(int(name_len * scale_factor)) label = ipywidgets.Label(axis.name, padding=u'0.3em', width=width) hbox = ipywidgets.HBox(children=[label, slider]) children.append(hbox) # Layout the sliders in a consitent order. self.form = ipywidgets.VBox() key = lambda hbox: hbox.children[0].value self.form.children = sorted(children, key=key)
def define_site_description_image(self): '''Widgets for site description parameters''' self.w_latBut = widgets.Button(description='Browse Latitude Image') self.w_lat = widgets.Text( description='(Decimal degrees)', value='0', width=500) self.w_lonBut = widgets.Button(description='Browse Longitude Image') self.w_lon = widgets.Text( description='(Decimal degrees):', value='0', width=500) self.w_altBut = widgets.Button(description='Browse Altitude Image') self.w_alt = widgets.Text( description='(m):', value='0', width=500) self.w_stdlon_But = widgets.Button(description='Browse Standard Longitude Image') self.w_stdlon = widgets.Text( description='(Decimal degrees):', value='0', width=500) self.w_z_u_But = widgets.Button(description='Wind meas. height') self.w_z_u = widgets.Text( description='(m):', value=str(self.zu), width=500) self.w_z_T_But = widgets.Button(description='Air temp. meas. height') self.w_z_T = widgets.Text( description='(m):', value=str(self.zt), width=500) self.site_page = widgets.VBox([widgets.HTML('Select latitude image or type a constant value'), widgets.HBox([self.w_latBut, self.w_lat]), widgets.HTML('Select longitude image or type a constant value'), widgets.HBox([self.w_lonBut, self.w_lon]), widgets.HTML('Select altitude image or type a constant value'), widgets.HBox([self.w_altBut, self.w_alt]), widgets.HTML('Select standard longitude image or type a constant value'), widgets.HBox([self.w_stdlon_But, self.w_stdlon]), widgets.HTML('Select wind measurement height image or type a constant value'), widgets.HBox([self.w_z_u_But, self.w_z_u]), widgets.HTML('Select air temperature measurement height image or type a constant value'), widgets.HBox([self.w_z_T_But, self.w_z_T])]) self.w_latBut.on_click( lambda b: self._on_input_clicked(b, 'Latitude', self.w_lat)) self.w_lonBut.on_click( lambda b: self._on_input_clicked(b, 'Longitude', self.w_lon)) self.w_altBut.on_click( lambda b: self._on_input_clicked(b, 'Altitude', self.w_alt)) self.w_stdlon_But.on_click( lambda b: self._on_input_clicked(b, 'Standard Longitude', self.w_stdlon)) self.w_z_u_But.on_click( lambda b: self._on_input_clicked(b, 'Wind Measurement Height', self.w_z_u)) self.w_z_T_But.on_click( lambda b: self._on_input_clicked(b, 'Air Temperature Measurement Height', self.w_z_T))
def surface_properties_time_series(self): '''Widgets for canopy properties''' self.w_PT = widgets.BoundedFloatText( value=self.max_PT, min=0, description="Max. alphaPT", width=80) self.w_LAD = widgets.BoundedFloatText( value=self.x_LAD, min=0, description="LIDF param.", width=80) self.w_LAD.visible = False self.w_leafwidth = widgets.BoundedFloatText( value=self.leaf_width, min=0.001, description="Leaf width", width=80) self.w_zsoil = widgets.BoundedFloatText( value=self.z0soil, min=0, description="soil roughness", width=80) # Landcover classes and values come from IGBP Land Cover Type Classification self.w_lc = widgets.Dropdown( options={ 'WATER': 0, 'CONIFER EVERGREEN': 1, 'BROADLEAVED EVERGREEN': 2, 'CONIFER DECIDUOUS': 3, 'BROADLEAVED DECIDUOUS': 4, 'FOREST MIXED': 5, 'SHRUB CLOSED': 6, 'SHRUB OPEN': 7, 'SAVANNA WOODY': 8, 'SAVANNA': 9, 'GRASS': 10, 'WETLAND': 11, 'CROP': 12, 'URBAN': 13, 'CROP MOSAIC': 14, 'SNOW': 15, 'BARREN': 16 }, value=self.landcover, description="Land Cover Type", width=200) lcText = widgets.HTML(value='''Land cover information is used to estimate roughness. <BR> For shrubs, conifers and broadleaves we use the model of <BR> Schaudt & Dickinson (2000) Agricultural and Forest Meteorology. <BR> For crops and grasses we use a fixed ratio of canopy heigh''', width=100) self.calc_row_options() self.veg_page = widgets.VBox([widgets.HBox([self.w_PT, self.w_LAD, self.w_leafwidth]), widgets.HBox([self.w_zsoil, self.w_lc, lcText]), widgets.HBox([self.w_row, self.w_rowaz])], background_color='#EEE')
def surface_properties_image(self): '''Widgets for canopy properties''' self.w_PT_But = widgets.Button( description='Browse Initial alphaPT Image') self.w_PT = widgets.Text(description=' ', value=str(self.max_PT), width=500) self.w_LAD_But = widgets.Button( description='Browse Leaf Angle Distribution Image') self.w_LAD = widgets.Text(description='(degrees)', value=str(self.x_LAD), width=500) self.w_leafwidth_But = widgets.Button( description='Browse Leaf Width Image') self.w_leafwidth = widgets.Text(description='(m)', value=str(self.leaf_width), width=500) self.w_zsoil_But = widgets.Button( description='Browse Soil Roughness Image') self.w_zsoil = widgets.Text(description='(m)', value=str(self.z0soil), width=500) self.w_lc_But = widgets.Button( description='Browse Land Cover Image') # Landcover classes and values come from IGBP Land Cover Type Classification self.w_lc = widgets.Dropdown( options={ 'CROP': 12, 'GRASS': 10, 'SHRUB': 6, 'CONIFER': 1, 'BROADLEAVED': 4}, value=self.landcover, description=" ", width=300) lcText = widgets.HTML(value='''Land cover information is used to estimate roughness. <BR> For shrubs, conifers and broadleaves we use the model of <BR> Schaudt & Dickinson (2000) Agricultural and Forest Meteorology. <BR> For crops and grasses we use a fixed ratio of canopy height<BR>''', width=600) self.calc_row_options() self.veg_page = widgets.VBox([widgets.HTML('Select alphaPT image or type a constant value'), widgets.HBox([self.w_PT_But, self.w_PT]), widgets.HTML('Select leaf angle distribution image or type a constant value'), widgets.HBox([self.w_LAD_But, self.w_LAD]), widgets.HTML('Select leaf width image or type a constant value'), widgets.HBox([self.w_leafwidth_But, self.w_leafwidth]), widgets.HTML('Select soil roughness image or type a constant value'), widgets.HBox([self.w_zsoil_But, self.w_zsoil]), widgets.HTML('Select landcover image or type a constant value'), widgets.HBox([self.w_lc_But, self.w_lc]), lcText, widgets.HBox([self.w_row, self.w_rowaz])], background_color='#EEE') self.w_PT_But.on_click( lambda b: self._on_input_clicked(b, 'Initial alphaPT', self.w_PT)) self.w_LAD_But.on_click( lambda b: self._on_input_clicked(b, 'Leaf Angle Distribution', self.w_LAD)) self.w_leafwidth_But.on_click( lambda b: self._on_input_clicked(b, 'Leaf Width', self.w_leafwidth)) self.w_zsoil_But.on_click( lambda b: self._on_input_clicked(b, 'Soil Roughness', self.w_zsoil)) self.w_lc_But.on_click( lambda b: self._input_dropdown_clicked(b, 'Land Cover', self.w_lc))
def resistances_image(self): '''Widgets for resistance model selection''' self.w_res = widgets.ToggleButtons( description='Select TSEB model to run:', options={ 'Kustas & Norman 1999': 0, 'Choudhury & Monteith 1988': 1, 'McNaughton & Van der Hurk': 2}, value=self.res, width=300) self.w_PT_But = widgets.Button( description='Browse Initial alphaPT Image') self.w_PT = widgets.Text(description=' ', value=str(self.max_PT), width=500) self.w_KN_b_But = widgets.Button( description = 'Browse Resistance Parameter b Image') self.w_KN_b = widgets.Text( value=str(self.KN_b), description=' ', width=500) self.w_KN_c_But = widgets.Button( description = ('Browse Resistance Parameter c image')) self.w_KN_c = widgets.Text( value=str(self.KN_c), description='(m s-1 K-1/3)', width=500) self.w_KN_C_dash_But = widgets.Button( description = ("Browse Resistance Parameter C' Image")) self.w_KN_C_dash = widgets.Text( value=str(self.KN_C_dash), description="s1/2 m-1", width=500) self.KN_params_box = widgets.VBox([widgets.HTML('Select resistance parameter b image or type a constant value'), widgets.HBox([self.w_KN_b_But, self.w_KN_b]), widgets.HTML('Select resistance parameter c image or type a constant value'), widgets.HBox([self.w_KN_c_But, self.w_KN_c]), widgets.HTML('Select resistance parameter C\' image or type a constant value'), widgets.HBox([self.w_KN_C_dash_But, self.w_KN_C_dash])], background_color='#EEE') self.res_page = widgets.VBox([self.w_res, self.KN_params_box], background_color='#EEE') self.w_KN_b_But.on_click( lambda b: self._on_input_clicked(b, 'Resistance Parameter b', self.w_KN_b)) self.w_KN_c_But.on_click( lambda b: self._on_input_clicked(b, 'Resistance Parameter c', self.w_KN_c)) self.w_KN_C_dash_But.on_click( lambda b: self._on_input_clicked(b, 'Resistance Parameter C\'', self.w_KN_C_dash))