我们从Python开源项目中,提取了以下23个代码示例,用于说明如何使用ipywidgets.VBox()。
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 widget(self): box = widgets.VBox() self._update(box) return box
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 __init__(self): from moldesign.compute import packages self.toggle = ipy.ToggleButtons(options=['Python libs', 'Executables'], value='Python libs') self.toggle.observe(self.switch_pane, 'value') self.pyheader = ipy.HTML( '<span class="nbv-table-header nbv-width-med">Package</span> ' '<span class="nbv-table-header nbv-width-sm">Local version</span> ' '<span class="nbv-table-header nbv-width-sm">Expected version</span>' '<span class="nbv-width-sm"> </span>' # empty space '<span class="nbv-table-header nbv-width-lg">' ' Run calculations...</span>' '<span class="nbv-table-header nbv-width-med"> </span>') self.python_libs = ipy.VBox([self.pyheader] + [PyLibConfig(p) for p in packages.packages]) self.exeheader = ipy.HTML( '<span class="nbv-table-header nbv-width-med">Program</span> ' '<span class="nbv-table-header nbv-width-sm">Local version</span> ' '<span class="nbv-table-header nbv-width-sm">Docker version</span>' '<span class="nbv-width-sm"> </span>' # empty space '<span class="nbv-table-header nbv-width-lg">' ' Run calculations...</span>' '<span class="nbv-table-header nbv-width-med"> </span>') self.executables = ipy.VBox([self.exeheader] + [ExeConfig(p) for p in packages.executables]) self.children = [self.toggle, self.python_libs] super().__init__(children=self.children)
def create_param_widgets(self): from ipywidgets import VBox containers = [] if self.param_container: self.param_container.close() for param, value in self.params[self._method].items(): container = self.create_param_widget(param, value) containers.append(container) self.param_container = VBox(containers, description="Parameters") display(self.param_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, 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))
def _make_ui_pane(self, hostheight): layout = ipy.Layout(width='325px', height=str(int(hostheight.rstrip('px')) - 50) + 'px') #element_height = str(int(hostheight.rstrip('px')) - 125) + 'px' element_height = None # NOTE - element_height was used for the listbox-style orblist. # HOWEVER ipywidgets 6.0 only displays those as a dropdown. # This is therefore disabled until we can display listboxes again. -- AMV 7/16 # Orbital set selector self.status_element = ipy.HTML(layout=ipy.Layout(width='inherit', height='20px')) orbtype_label = ipy.Label("Orbital set:") self.type_dropdown = ipy.Dropdown(options=list(self.wfn.orbitals.keys())) initialtype = 'canonical' if initialtype not in self.type_dropdown.options: initialtype = next(iter(self.type_dropdown.options.keys())) self.type_dropdown.value = initialtype self.type_dropdown.observe(self.new_orb_type, 'value') # List of orbitals in this set orblist_label = ipy.Label("Orbital:") self.orblist = ipy.Dropdown(options={None: None}, layout=ipy.Layout(width=layout.width, height=element_height)) traitlets.link((self.orblist, 'value'), (self, 'current_orbital')) # Isovalue selector isoval_label = ipy.Label('Isovalue:') self.isoval_selector = ipy.FloatSlider(min=0.0, max=0.075, value=0.01, step=0.00075, readout_format='.4f', layout=ipy.Layout(width=layout.width)) traitlets.link((self.isoval_selector, 'value'), (self, 'isoval')) # Opacity selector opacity_label = ipy.Label('Opacity:') self.opacity_selector = ipy.FloatSlider(min=0.0, max=1.0, value=0.8, step=0.01, readout_format='.2f', layout=ipy.Layout(width=layout.width)) traitlets.link((self.opacity_selector, 'value'), (self, 'orb_opacity')) # Resolution selector resolution_label = ipy.Label("Grid resolution:", layout=ipy.Layout(width=layout.width)) self.orb_resolution = ipy.Text(layout=ipy.Layout(width='75px', positioning='bottom')) self.orb_resolution.value = str(self.numpoints) self.resolution_button = ipy.Button(description='Update resolution') self.resolution_button.on_click(self.change_resolution) traitlets.directional_link((self, 'numpoints'), (self.orb_resolution, 'value'), transform=str) self.uipane = ipy.VBox([self.status_element, orbtype_label, self.type_dropdown, orblist_label, self.orblist, isoval_label, self.isoval_selector, opacity_label, self.opacity_selector, resolution_label, self.orb_resolution, self.resolution_button]) self.new_orb_type() self.type_dropdown.observe(self.new_orb_type, 'value') return self.uipane