def get_srm2(self): self.FNO2_srm2 = widgets.BoundedFloatText(value=.199, min=0., max=1.0, step=.01, description='FNO2_srm2:', disabled=False) self.conc_NOx_srm2 = widgets.BoundedFloatText( value=1.776, min=0., max=100., description='Conc NOx SRM2:', disabled=False) self.conc_PM10_srm2 = widgets.BoundedFloatText( value=.095875, min=0., max=100., description='Conc PM10 SRM2:', disabled=False) self.conc_PM25_srm2 = widgets.BoundedFloatText( value=.04, min=0., max=100., description='Conc PM2.5 SRM2:', disabled=False) display(self.FNO2_srm2) display(self.conc_NOx_srm2) display(self.conc_PM10_srm2) display(self.conc_PM25_srm2)
def __init__(self): align_kw = dict(_css=(('.widget-label', 'min-width', '5000ex'), ), margin='10px 20px 5px 12px') style = {'description_width': '150px'} layout = {'width': '300px'} self.RDW_x = widgets.BoundedFloatText(value=133382.0, min=0., max=280000.0, step=10., description='RDW_x (m East):', disabled=False, style=style, layout=layout) self.RDW_y = widgets.BoundedFloatText(value=454361., min=30000.0, max=640000.0, description='RDW_y (m North):', disabled=False, style=style, layout=layout) self.year = widgets.widget_selection.Dropdown( options=[2020, 2025, 2030], value=2020, description='Year', disabled=False, style=style, layout=layout) display(self.RDW_x) display(self.RDW_y) display(self.year)
def twostream_widget(): style = {'description_width': '350px'} layout = Layout(width='55%') a = ipywidgets.Text(value='2stream.txt', description='Template Input File:',style=style,layout=layout) b = ipywidgets.Text(value='case1.txt', description='New Output File:',style=style,layout=layout) c = ipywidgets.BoundedFloatText(value=5, min=-30.0, max=30.0, description='Stream #1 Velocity (set first!):',style=style,layout=layout) d = ipywidgets.BoundedFloatText(value=-5, min=-30.0, max=30.0, description='Stream #2 Velocity:',style=style,layout=layout) e = ipywidgets.BoundedFloatText(value=1, min=0.0001, max=10.0, description='Density Ratio (n2/n1):',style=style,layout=layout) f = ipywidgets.BoundedFloatText(value=1, min=1, max=1, description='Stream #1 Density is fixed:',style=style,layout=layout) g = ipywidgets.FloatText(value=100.0,description='TEND or the Total Simulation Time:',style=style,layout=layout) h = ipywidgets.IntText(value=8,description='Box Length (In powers of 2!):',style=style,layout=layout) im = interact_calc(twostream_deck_maker, iname=a, oname=b, n1=f, vx0=c, vdx=d, n2n1=e, tend=g, indx=h); def c_handle_slider_change(change): d.value = -1/e.value*change.new c.observe(c_handle_slider_change, names='value') def d_handle_slider_change(change): e.value = -1/change.new*c.value d.observe(d_handle_slider_change, names='value') def e_handle_slider_change(change): d.value = -1/change.new*c.value e.observe(e_handle_slider_change, names='value') im.widget.manual_button.layout.width='300px'
def dynamicFloatValue_Magnet_Position(num_of_magnets, magnet_dimensions, global_bounds): listOfWidgets = [] j = 0 for i in range(num_of_magnets): widget1 = widgets.BoundedFloatText( value=0, max=(global_bounds[0].value - magnet_dimensions[j + 1].value), min=(global_bounds[1].value), description=f'x pos {i+1}', ) widget2 = widgets.BoundedFloatText( value=0, max=(global_bounds[2].value - 0.5 * magnet_dimensions[j].value), min=(global_bounds[3].value + 0.5 * magnet_dimensions[j].value), description=f'y pos {i+1}', ) widget3 = widgets.BoundedFloatText( value=0, max=(global_bounds[4].value - 0.5 * magnet_dimensions[j + 2].value), min=(global_bounds[5].value + 0.5 * magnet_dimensions[j + 2].value), description=f'z pos {i+1}', ) listOfWidgets.extend([widget1, widget2, widget3]) j += 3 return listOfWidgets
def directionalderivative(): func = widgets.Dropdown(options=['Ex_4','Ex_5'], value='Ex_5', description='Select Example') # spatial slider xzoom = widgets.FloatRangeSlider(value=[-2.,2.], min=-5., max=5., step=0.1, continuous_update=False, description='x range for contour plot') yzoom = widgets.FloatRangeSlider(value=[-2.,2.], min=-5, max=5., step=0.1, continuous_update=False, description='y range for contour plot') view_grad = widgets.Checkbox(value=False, description='View gradient vector field') # point at which to evaluate partial derivatives pt_x = widgets.BoundedFloatText(value=0.4, min=-5., max=5., step=0.1, description='x coordinate of starting point', continuous_update=False, disabled=False) pt_y = widgets.BoundedFloatText(value=0.2, min=-5., max=5., step=0.1, description='y coordinate of starting point', continuous_update=False, disabled=False) # point at which to evaluate partial derivatives dir_x = widgets.BoundedFloatText(value=1., min=-2., max=2., step=0.1, description='x of direction vector', continuous_update=False, disabled=False) dir_y = widgets.BoundedFloatText(value=1., min=-2., max=2., step=0.1, description='y of direction vector', continuous_update=False, disabled=False) dir_norm = widgets.Checkbox(value=True, description='normalise the vector direction', disabled=True) # interactive output return widgets.VBox([widgets.HBox([func]),\ widgets.HBox([xzoom,yzoom,view_grad]),\ widgets.HBox([pt_x,pt_y]),\ widgets.HBox([dir_x,dir_y,dir_norm]),\ widgets.interactive_output(directionalderivative_run,\ {'func':func,'xzoom':xzoom,'yzoom':yzoom,'view_grad':view_grad,\ 'pt_x':pt_x,'pt_y':pt_y,\ 'dir_x':dir_x,'dir_y':dir_y,'dir_norm':dir_norm})])
def init_elements(self): self.title = ipw.HTML("<h3>Numerical Parameters</h3>") self.maxiter_inner_slider = ipw.IntSlider( min=0, max=100, value=self.params.maxiter_inner, description=r'maxiter_inner' ) self.maxiter_outer_slider = ipw.IntSlider( min=0, max=100, value=self.params.maxiter_outer, description=r'maxiter_outer' ) self.tol_abs_picker = ipw.BoundedFloatText( min=0, max=10, value = self.params.tol_abs, description = 'Tol_Abs' ) self.tol_rel_picker = ipw.BoundedFloatText( min=0, max=10, value = self.params.tol_rel, description = 'Tol_Rel' ) self.num_scatters_spinner = ipw.BoundedIntText( description='# of scatters', min=0, max=10 ) self.gmres_checkbox = ipw.Checkbox( description='Full RTE w/ GMRES' )
def _add_inputs(self): u"""Add inputs and update button.""" val_min = self._brain.data['fmin'] val_mid = self._brain.data['fmid'] val_max = self._brain.data['fmax'] if self._brain.data['center'] is None: # 'hot' color map sl_min = -sys.float_info.max else: # 'mne' color map sl_min = self._brain.data['center'] self._input_fmin = widgets.BoundedFloatText(value=round(val_min, 2), min=sl_min, description='Fmin:', step=0.1, disabled=False) self._input_fmid = widgets.BoundedFloatText(value=round(val_mid, 2), min=sl_min, description='Fmid:', step=0.1, disabled=False) self._input_fmax = widgets.BoundedFloatText(value=round(val_max, 2), min=sl_min, description='Fmax:', step=0.1, disabled=False) self._btn_upd_mesh = widgets.Button(description='Update mesh', disabled=False, button_style='', tooltip='Update mesh')
def createPanel(self): context = self.context Ei = context.Ei Qmin = 0 from multiphonon.units.neutron import e2k Qmax = round2(e2k(Ei) * 2 * 1.5, digits=2) self.text_Qmin = ipyw.BoundedFloatText( description='Qmin', value=(Qmin if context.Qmin is None else context.Qmin), min=Qmin, max=Qmax) self.text_Qmax = ipyw.BoundedFloatText( description='Qmax', value=(Qmax if context.Qmax is None else context.Qmax), min=Qmin, max=Qmax) self.text_dQ = ipyw.BoundedFloatText( description='dQ', value=(round2(Qmax / 100.) if context.dQ is None else context.dQ), min=0., max=Qmax / 5) OK = ipyw.Button(description='OK') OK.on_click(self.handle_next_button_click) widgets = [self.text_Qmin, self.text_Qmax, self.text_dQ, OK] return ipyw.VBox(children=widgets)
def __init__(self, node, disabled=None): if disabled == None: self.disabled = [False, False, False] else: self.disabled = disabled self.is_categorical = node.vartype == 'categorical' self.name = node.name self.text = wd.Label(value=self.name, layout=wd.Layout(width='180px')) self.none = wd.RadioButtons(options=['No intervention'], disabled=self.disabled[0], layout=wd.Layout(width='150px')) self.fixed = wd.RadioButtons(options=['Fixed'], disabled=self.disabled[1], layout=wd.Layout(width='70px')) self.fixed.index = None if self.is_categorical: fixed_arg = wd.Dropdown(options=node.categories, disabled=True, layout=wd.Layout(width='100px')) else: fixed_arg = wd.BoundedFloatText(disabled=True, layout=wd.Layout(width='70px')) self.fixed_arg = fixed_arg self.range_visibility = 'hidden' if self.is_categorical else 'visible' self.range = wd.RadioButtons(options=['Range'], disabled=self.disabled[2], layout=wd.Layout(width='70px', visibility=self.range_visibility)) self.range.index = None self.range_arg1_text = wd.Label(value='from', layout=wd.Layout(visibility=self.range_visibility, width='30px')) self.range_arg1 = wd.BoundedFloatText(min=node.min, max=node.max, disabled=True, layout=wd.Layout(width='70px', visibility=self.range_visibility)) self.range_arg2_text = wd.Label(value='to', layout=wd.Layout(visibility=self.range_visibility, width='15px')) self.range_arg2 = wd.BoundedFloatText(min=node.min, max=node.max, disabled=True, layout=wd.Layout(width='70px', visibility=self.range_visibility)) self.range_rand = wd.Checkbox(description='Randomise Order', disabled=True, indent=False, layout=wd.Layout(visibility=self.range_visibility)) self.none.observe(self.none_observer, names=['value']) self.fixed.observe(self.fixed_observer, names=['value']) self.range.observe(self.range_observer, names=['value']) self.box = wd.HBox([self.text, self.none, self.fixed, self.fixed_arg, self.range, self.range_arg1_text, self.range_arg1, self.range_arg2_text, self.range_arg2, self.range_rand])
def single_particle_widget(run_osiris=True): style = {'description_width': '350px'} layout = Layout(width='55%') a = widgets.Text(value='single-part-1', description='New output file:', style=style, layout=layout) b = widgets.Dropdown(options=['yee', 'fei'], value='yee', description='Field solver:', style=style, layout=layout) c = widgets.BoundedFloatText(value=600.0, min=40.0, max=1e9, description='t_final:', style=style, layout=layout) d = widgets.BoundedFloatText(value=0.95, min=0.0, max=1.0, description='dt/t_courant:', style=style, layout=layout) e = widgets.Dropdown( options=['standard', 'vay', 'cond_vay', 'cary', 'fullrot', 'euler'], value='standard', description='Pusher:', style=style, layout=layout) f = widgets.FloatText(value=0.0, description='uz0:', style=style, layout=layout) g = widgets.BoundedFloatText(value=1.0, min=0, max=1e3, description='a0:', style=style, layout=layout) h = widgets.BoundedFloatText(value=0.0, min=-180, max=180, description='phi0 (degrees):', style=style, layout=layout) im = interact_calc(newifile, oname=a, field_solve=b, t_final=c, dt=d, pusher=e, uz0=f, a0=g, phi0=h, run_osiris=fixed(run_osiris)) im.widget.manual_button.layout.width = '250px' return a
def calcula_min_max(): global min_range, max_range, boton_range var = dataset.variables[variables[0][propiedades[0]]][:] v_m = np.amin(var[:]) if v_m != np.nan and v_m <= 0: var[var == v_m] = np.nan v_mean = np.nanmean(var[:]) v_max = np.nanmax(var[:]) v_min = np.nanmin(var[:]) propiedades[3] = v_min propiedades[4] = v_max propiedades[5] = v_mean #Casillas para escoger e rango de valores que se quieren mostrar min_range = widgets.BoundedFloatText(value=propiedades[3], min=propiedades[3], max=propiedades[4], step=1, description='Min:') max_range = widgets.BoundedFloatText(value=propiedades[4], min=propiedades[3], max=propiedades[4], step=1, description='Max:') boton_range = widgets.Button(description='Change range') boton_range.on_click(on_button_clicked_range)
def __init__(self, bandits, gui=False): self.grp_picker = wid.Dropdown( options=[('All', None), ('Free', 0), ('Strategic', 1)], value=None, description='Group: ', layout=wid.Layout(width='30%'), ) self.ntm_picker = wid.Dropdown( options=[('All', None), ('1', 1), ('2', 2), ('3', 3)], value=None, description='NTM: ', layout=wid.Layout(width='30%'), ) self.slides = {} self.params_dict = {} for tid, tsk in enumerate(bandits): b0slide = wid.BoundedFloatText(value=1., min=-3., max=3., step=0.01, layout=wid.Layout(width='200pt'), description='b0: '.format(tsk), continuous_update=False, orientation='horizontal') b1slide = wid.BoundedFloatText(value=1., min=-2., max=2., step=0.001, layout=wid.Layout(width='200pt'), description='b1: '.format(tsk), continuous_update=False, orientation='horizontal') label = wid.HTML(value='<b><font color="{}">{}</b>'.format( colors[tid], tsk), layout=wid.Layout(width='10pt')) self.slides[tid + 1] = (label, b0slide, b1slide) self.params_dict[tid + 1] = (b0slide.value, b1slide.value) self.sim_n = wid.IntText(value=150, description='Runs:') self.sim_t = wid.IntText(value=30, description='Trials/run:') self.reset_button = wid.Button(description='Fit to all data', button_style='warning') self.reset_button.on_click(lambda x: self.reset()) if gui: self.fig = plt.figure('Hits generator', figsize=[8.5, 4]) self.ax1, self.ax2 = vut.pretty(self.fig.add_subplot( 1, 2, 1)), vut.pretty(self.fig.add_subplot(1, 2, 2)) self.ax1.set_ylim(.4, 1.02) self.ax1.set_xlim(0, 250) self.ax2.set_ylim(.4, 1.02) self.ax1.set_title('$P(hit \mid trial)$') self.ax2.set_title('Simulated data') self.axes = [self.ax1, self.ax2] self.controls_on()
def setup_controls(self): down = ipywidgets.Button(icon="arrow-down", layout=ipywidgets.Layout(width='40px')) up = ipywidgets.Button(icon="arrow-up", layout=ipywidgets.Layout(width='40px')) right = ipywidgets.Button(icon="arrow-right", layout=ipywidgets.Layout(width='40px') ) left = ipywidgets.Button(icon="arrow-left", layout=ipywidgets.Layout(width='40px') ) zoom_start = 1./(self.view_width[0]) zoom = ipywidgets.FloatSlider(min=0.1, max=10, step=0.1, value=zoom_start, description="Zoom") is_log = ipywidgets.Checkbox(value=False, description="Log colorscale") colormaps = ipywidgets.Dropdown( options=list(self.colormaps.cmaps.keys()), description="colormap", value = "viridis") min_val = ipywidgets.BoundedFloatText(description="lower colorbar bound:", value=self.val.min(), min=self.val.min(), max=self.val.max()) max_val = ipywidgets.BoundedFloatText(description="upper colorbar bound:", value=self.val.max(), min=self.val.min(), max=self.val.max()) minmax = ipywidgets.FloatRangeSlider(min=self.val.min(), max=self.val.max()) down.on_click(self.on_ydownclick) up.on_click(self.on_yupclick) right.on_click(self.on_xrightclick) left.on_click(self.on_xleftclick) zoom.observe(self.on_zoom, names='value') # These can be jslinked, so we will do so. ipywidgets.jslink((is_log, 'value'), (self.colormaps, 'is_log')) ipywidgets.jslink((min_val, 'value'), (self.colormaps, 'min_val')) ipywidgets.jslink((max_val, 'value'), (self.colormaps, 'max_val')) # This one seemingly cannot be. ipywidgets.link((colormaps, 'value'), (self.colormaps, 'map_name')) sides = ipywidgets.HBox([left,right], layout=ipywidgets.Layout(justify_content='space-between', width='122px')) nav_buttons = ipywidgets.VBox([up, sides, down], layout=ipywidgets.Layout( align_items='center', width='150px')) all_navigation = ipywidgets.VBox([nav_buttons, zoom], layout=ipywidgets.Layout(align_items='center') ) all_normalizers = ipywidgets.VBox([is_log, colormaps, min_val, max_val], layout=ipywidgets.Layout(align_items='center') ) accordion = ipywidgets.Accordion(children=[all_navigation, all_normalizers]) accordion.set_title(0, 'navigation') accordion.set_title(1, 'colormap controls') return accordion
def representation_complexe(): real = widgets.BoundedFloatText(value=1, min=-2.0, max=2.0, step=0.1, disabled=True) imag = widgets.BoundedFloatText(value=1, min=-2.0, max=2.0, step=0.1, disabled=True) sc_x = bqplot.LinearScale(min=-2, max=2) sc_y = bqplot.LinearScale(min=-2, max=2) ax_x = bqplot.Axis(scale=sc_x, offset=dict(value=0.5), grid_lines='none') ax_y = bqplot.Axis(scale=sc_y, orientation='vertical', offset=dict(value=0.5), grid_lines='none') z_point = bqplot.Scatter(x=[real.value], y=[imag.value], scales={ 'x': sc_x, 'y': sc_y }, colors=['green'], enable_move=True) z_point.update_on_move = True fig = bqplot.Figure(marks=[z_point], axes=[ax_x, ax_y], min_aspect_ratio=1, max_aspect_ratio=1) complex_z = widgets.HBox([ widgets.Label('$z = $'), real, widgets.Label('$ + $'), imag, widgets.Label('$i$') ]) def update_z(change=None): real.value = z_point.x[0] imag.value = z_point.y[0] z_point.observe(update_z, names=['x', 'y']) #def update_point(change=None): # z_point.x = [real.value] # z_point.y = [imag.value] #real.observe(update_point, names='value') #imag.observe(update_point, names='value') return widgets.VBox([fig, complex_z], layout=widgets.Layout(align_items="center"))
def set_widgets(): global drop_var, drop_date, depth_wid, hb_3d, hb_2d, vb_ev_2d, vb_ev_3d, valor_x, valor_y, date, vb_corte #widgets para escoger que datos mostrar drop_var = widgets.Dropdown( options=[(variables[0][n], n) for n in range(len(variables[0]))], value=0, description='Variables:', ) date = set_date() drop_date = widgets.Dropdown( options=[(str(date[i]), i) for i in range(len(date))], value=0, description='Date:', ) drop_date.observe(date_on_change, names='value') drop_var.observe(variable_on_change, names='value') hb_3d = HBox([drop_var, drop_date, depth_wid]) hb_2d = HBox([drop_var, drop_date]) #cuadro de texto para donde se escoge el valor de coordenada x e y valor_x = widgets.BoundedFloatText(value=0, min=0, max=92, step=1, description='x:') valor_y = widgets.BoundedFloatText(value=0, min=0, max=119, step=1, description='y:') #widgets para ver más info boton_tiempo = widgets.Button(description='Time') boton_prof = widgets.Button(description='Depth') boton_corte_lon = widgets.Button(description='Corte lon') boton_corte_lat = widgets.Button(description='Corte lat') Label_cor = widgets.Label("Click on the map to choose the coordinates:") vb_ev_text = VBox([valor_x, valor_y]) vb_ev_bot = VBox([boton_tiempo, boton_prof]) hb_ev_3d = HBox([vb_ev_text, vb_ev_bot]) hb_ev_2d = HBox([vb_ev_text, boton_tiempo]) vb_ev_3d = VBox([Label_cor, hb_ev_3d]) vb_ev_2d = VBox([Label_cor, hb_ev_2d]) vb_corte = VBox([boton_corte_lat, boton_corte_lon]) boton_prof.on_click(on_button_clicked_ev_prof) boton_tiempo.on_click(on_button_clicked_ev_time) boton_corte_lat.on_click(on_button_clicked_corte_lat) boton_corte_lon.on_click(on_button_clicked_corte_lon)
def make_roughness_calculations(self): ''' This creates all the widgets for calculating slope, curvature, etc Author: SMM Date: 14/07/2020 ''' wide_style = {'description_width': 'initial'} this_dict = {} print_REI_raster = widgets.Checkbox(value=False, description='print_REI_raster', disabled=False, indent=False) this_dict.update({"print_REI_raster": print_REI_raster}) REI_window_radius = widgets.BoundedFloatText( value=10, min=1, max=500, step=1, description='REI_window_radius', disabled=False, style=wide_style) this_dict.update({"REI_window_radius": REI_window_radius}) REI_critical_slope = widgets.BoundedFloatText( value=1.0, min=0.4, max=2.0, step=0.05, description='REI_critical_slope:', disabled=False, style=wide_style) this_dict.update({"REI_critical_slope": REI_critical_slope}) print_roughness_rasters = widgets.Checkbox( value=False, description='print_roughness_rasters', disabled=False, indent=False) this_dict.update({"print_roughness_rasters": print_roughness_rasters}) roughness_radius = widgets.BoundedFloatText( value=3, min=1, max=500, step=0.2, description='roughness_radius', disabled=False, style=wide_style) this_dict.update({"roughness_radius": roughness_radius}) return this_dict
def createParameterInputWidgets(context): from collections import OrderedDict import ipywidgets as widgets w_mt_fraction = widgets.BoundedFloatText(description="mt_fraction", min=0., max=1., value=context.mt_fraction) w_const_bg_fraction = widgets.BoundedFloatText( description="const_bg_fraction", min=0., max=1., value=context.const_bg_fraction) w_Ecutoff = widgets.BoundedFloatText(description="Max energy of phonons", min=0, max=context.Ei, value=context.Ecutoff) w_ElasticPeakMin = widgets.BoundedFloatText( description="Emin of elastic peak", min=-context.Ei / 2., max=0., value=context.ElasticPeakMin) w_ElasticPeakMax = widgets.BoundedFloatText( description="Emax of elastic peak", min=0., max=context.Ei / 2., value=context.ElasticPeakMax) w_M = widgets.BoundedFloatText(description="Average atom mass", min=1., max=1000., value=context.M) w_C_ms = widgets.BoundedFloatText(description="C_ms", min=0., max=10., value=context.C_ms) update_strategy_weights = context.update_strategy_weights w_update_weight_continuity = widgets.BoundedFloatText( description='"enforce continuity" weight for DOS update strategy', min=0., max=1., value=update_strategy_weights[0]) w_update_weight_area = widgets.BoundedFloatText( description='"area conservation" weight for DOS update strategy', min=0., max=1., value=update_strategy_weights[1]) w_inputs = OrderedDict( mt_fraction=w_mt_fraction, const_bg_fraction=w_const_bg_fraction, Ecutoff=w_Ecutoff, ElasticPeakRange=(w_ElasticPeakMin, w_ElasticPeakMax), M=w_M, C_ms=w_C_ms, update_weights=(w_update_weight_continuity, w_update_weight_area), ) w_Run = widgets.Button(description="Run") return w_inputs, w_Run
def wcb_widget(): style = {'description_width': '350px'} layout = Layout(width='55%') a = ipywidgets.Text(value='wcb.txt', description='Template Input File:', style=style, layout=layout) b = ipywidgets.Text(value='case1.txt', description='New Output File:', style=style, layout=layout) c = ipywidgets.BoundedFloatText(value=3, min=0.0, max=10.0, description='Electron Drift Velocity:', style=style, layout=layout) d = ipywidgets.BoundedFloatText(value=0.01, min=0.01, max=1, step=0.01, description='Density Ratio (n_b/n_0):', style=style, layout=layout) e = ipywidgets.FloatText(value=1.0, description='VTH (of the plasma):', style=style, layout=layout) f = ipywidgets.BoundedFloatText(value=0.1, min=0, max=1, step=0.1, description='VTH (of the beam):', style=style, layout=layout) g = ipywidgets.FloatText(value=200.0, description='TEND or the Total Simulation Time:', style=style, layout=layout) im = interact_calc(wcb_deck_maker, iname=a, oname=b, vdx=c, rden=d, vth0=e, vthb=f, tend=g) im.widget.manual_button.layout.width = '300px'
def single_particle_widget(): style = {'description_width': '350px'} layout = Layout(width='55%') a = widgets.Text(value='single-part-1.txt', description='New output file:',style=style,layout=layout) b = widgets.Dropdown(options=['yee', 'fei'],value='yee', description='Field solver:',style=style,layout=layout) c = widgets.BoundedFloatText(value=600.0, min=0.0, max=1e9, description='t_final:',style=style,layout=layout) d = widgets.Dropdown(options=['standard', 'vay', 'cond_vay', 'cary'],value='standard',description='Pusher:',style=style,layout=layout) e = widgets.FloatText(value=0.0, description='uz0:',style=style,layout=layout) f = widgets.BoundedFloatText(value=1.0, min=0, max=1e3, description='a0:',style=style,layout=layout) g = widgets.BoundedFloatText(value=0.0, min=-180, max=180, description='phi0 (degrees):',style=style,layout=layout) im = interact_calc(newifile, oname=a,field_solve=b,t_final=c,pusher=d,uz0=e,a0=f,phi0=g); im.widget.manual_button.layout.width='250px'
def createPanel(self): context = self.context self.text_Ei = ipyw.BoundedFloatText(description="Ei (meV)", value=context.Ei, min=0., max=10000) self.text_T = ipyw.BoundedFloatText(description="Temperature (Kelvin)", value=context.T, min=0., max=10000) OK = ipyw.Button(description='OK') OK.on_click(self.handle_next_button_click) widgets = [self.text_Ei, self.text_T, OK] return ipyw.VBox(children=widgets)
def __init__(self): #elemenets self._element = widgets.Select( options=_global_element_list, description='Element', layout=widgets.Layout( #flex='0 1 auto', #height=_element_height, width=_element_width, height=_element_height, #width='60px' )) #blank min self._massfrac_min = widgets.BoundedFloatText( min=0., max=1., description='Min' # layout=widgets.Layout( # flex='0 1 auto', # width='auto' # ) ) #blank max self._massfrac_max = widgets.BoundedFloatText( min=0., max=1., description='Max' # ,layout=widgets.Layout( # flex='0 1 auto', # width='auto' # ) ) # for x in ['massfrac_min', 'massfrac_max']: # getattr(self, '_' + x).margin = 0 box_layout = widgets.Layout( overflow_x='scroll', #border='1px solid black', width='80%', flex_direction='row', display='flex') self._box = widgets.HBox( layout=box_layout) #width=(_element_width + 2* _num_width)) self._box.children = (self._element, self._massfrac_min, self._massfrac_max)
def user_prior_component(prior_name: str, unit_name: Optional[str] = None, _handle_change=None, mu=None, unc=None): _mu_checkbox = widgets.Checkbox(value=mu is not None, description='Value') _unc_checkbox = widgets.Checkbox(value=unc is not None, description='Uncertainty') if mu is None: mu = 0.5 _mu_field = widgets.BoundedFloatText(value=mu, min=0.01, step=0.1) if unc is None: unc = 0.1 _unc_field = widgets.BoundedFloatText(value=unc, min=0.0, step=0.05) def _update_state(b): state_dict = {prior_name: {}} if _mu_checkbox.value: state_dict[prior_name]['mu'] = _mu_field.value if _unc_checkbox.value: state_dict[prior_name]['unc'] = _unc_field.value _handle_change(state_dict) _mu_checkbox.observe(_update_state) _mu_field.observe(_update_state) _unc_checkbox.observe(_update_state) _unc_field.observe(_update_state) html_layout = widgets.Layout(display='flex', flex_flow='row', justify_content='center') box_layout = widgets.Layout(display='flex', flex_flow='row') label_text = prior_name if unit_name is not None and unit_name != '': label_text = f'{prior_name} ({unit_name})' items = [ widgets.Box([widgets.HTML(value=html_element('h3', value=label_text))], layout=html_layout), widgets.Box([_mu_checkbox, _mu_field], layout=box_layout), widgets.Box([_unc_checkbox, _unc_field], layout=box_layout) ] form = widgets.Box(items, layout=widgets.Layout( display='flex', flex_flow='column', align_items='stretch', width='100%', )) return form
def _widget_factory(field: FormField): kwargs = { 'description': field.label, 'description_tooltip': field.description } if isinstance(field, IntegerField): widget = ipywidgets.BoundedIntText(value=field.default, min=field.min, max=field.max, **kwargs) elif isinstance(field, DecimalField): widget = ipywidgets.BoundedFloatText(value=field.default, min=field.min, max=field.max, **kwargs) elif isinstance(field, TextField): widget = ipywidgets.Text(placeholder=field.default, **kwargs) elif isinstance(field, BooleanField): widget = ipywidgets.Checkbox(value=field.default, **kwargs) elif isinstance(field, ChoiceField): kwargs.update(options=field.choices) if field.multiple: widget = ipywidgets.SelectMultiple(value=[field.default], **kwargs) elif len(field.choices) <= 5: widget = ipywidgets.RadioButtons(value=field.default, **kwargs) else: widget = ipywidgets.Dropdown(value=field.default, **kwargs) elif isinstance(field, FileField): widget = ipywidgets.FileUpload(accept=field.media_type or field.extension, **kwargs) else: raise TypeError(type(field)) widget.field_name = field.name return widget
def make_junction_angles(self): ''' This creates all the widgets for calculating slope, curvature, etc Author: SMM Date: 14/07/2020 ''' wide_style = {'description_width': 'initial'} this_dict = {} SA_vertical_interval = widgets.BoundedFloatText( value=10, min=1, max=200, step=0.1, description='SA_vertical_interval', disabled=False, style=wide_style) this_dict.update({"SA_vertical_interval": SA_vertical_interval}) print_junction_angles_to_csv = widgets.Checkbox( value=False, description='print_junction_angles_to_csv', disabled=False, indent=False) this_dict.update( {"print_junction_angles_to_csv": print_junction_angles_to_csv}) return this_dict
def run_colab(population_size, network_pkl): G = load_network(network_pkl) population = genetic_algo.Population(G, population_size) phenotypes = _generate_phenotypes(population, G) board = Box(children=phenotypes, layout=Layout(display="flex", flex_flow="row wrap")) mutationInput = widgets.BoundedFloatText(value=0.01,min=0.0,max=1.0,step=0.01, layout=Layout(width="100px")) button = widgets.Button(description="Update") button.on_click(lambda _: _update(population, mutationInput, G, board, loading, button)) mutationInputBox = widgets.VBox([Label("Taxa de mutação:"), mutationInput]) loading = widgets.FloatProgress( value=100, min=0, max=100, bar_style='info', style={'bar_color': '#008080'}, orientation='horizontal' ) bottomBox = Box( children=[mutationInputBox, loading, button], layout=Layout( display="flex", width="100%", justify_content="space-between", align_items="flex-end", padding="0 15% 20px 0", ), ) app = widgets.VBox([board, bottomBox]) display(app)
def buneman_widget(): style = {'description_width': '350px'} layout = Layout(width='55%') a = ipywidgets.Text(value='buneman.txt', description='Template Input File:', style=style, layout=layout) b = ipywidgets.Text(value='case1.txt', description='New Output File:', style=style, layout=layout) c = ipywidgets.BoundedFloatText(value=3, min=0.0, max=10.0, description='Electron Drift Velocity:', style=style, layout=layout) d = ipywidgets.FloatText(value=100.0, description='Mass Ratio (M/m):', style=style, layout=layout) e = ipywidgets.FloatText(value=200.0, description='TEND or the Total Simulation Time:', style=style, layout=layout) im = interact_calc(buneman_deck_maker, iname=a, oname=b, VX0=c, RMASS=d, tend=e) im.widget.manual_button.layout.width = '250px'
def create_bins_cust(self): children = [] for val in self.bins: float_box = widgets.BoundedFloatText( value=val, layout=widgets.Layout(width='80px'), step=0.1) children.append(float_box) self.children = children
def __init__(self, motor, config=Configuration(), *args, **kwargs): widgets.Button.__init__(self, *args, **kwargs) # Config self.config = config # Motor associated to the button self.motor = motor if type(motor) != py4syn.epics.MotorClass.Motor: logprint("Passed to class MotorSetValueButton constructor a argument with wrong type. Expected py4syn.epics.MotorClass.Motor, received " + str(type(motor)), config=self.config) raise("Passed to class MotorSetValueButton constructor a argument with wrong type. Expected py4syn.epics.MotorClass.Motor, received " + str(type(motor))) # Bounded float text associated to the button self.bounded_float = widgets.BoundedFloatText( value=motor.getRealPosition(), min=motor.getLowLimitValue(), max=motor.getHighLimitValue(), step=0.01, description=motor.motorDesc, disabled=False ) # class Button values for MotorSetValueButton self.description = 'Set Target VAL' self.disabled = False self.button_style = 'success' self.tooltip = 'Click me' self.icon = '' # Set callback function for click event self.on_click(self._motor_set_val_button) # Widgets Boxes self.output = widgets.Output()
def select_n2v_parameter(): ### N2V neighbor radius ################### int_n2v_neighborhood_radius = widgets.BoundedIntText(min=1, max=4096, step=1, value=params['n2v_neighborhood_radius']) def on_n2v_neighborhood_radius_change(change): params['n2v_neighborhood_radius'] = change.new int_n2v_neighborhood_radius.observe(on_n2v_neighborhood_radius_change, 'value') ### N2V perc pixel ################### float_n2v_perc_pix = widgets.BoundedFloatText(min=0, max=100, step=0.001, value=params['n2v_perc_pix']) def on_n2v_perc_pix_change(change): params['n2v_perc_pix'] = change.new float_n2v_perc_pix.observe(on_n2v_perc_pix_change, 'value') text_n2v_name = widgets.Text(value=params['name']) def on_text_n2v_name_change(change): params['name'] = change.new text_n2v_name.observe(on_text_n2v_name_change, 'value') ### Combine ############## n2v_parameter = widgets.VBox([ widgets.HBox([widgets.Label('Neighborhood radius', layout={'width':'200px'}), int_n2v_neighborhood_radius]), widgets.HBox([widgets.Label('Percent pixel manipulation', layout={'width':'200px'}), float_n2v_perc_pix]), widgets.HBox([widgets.Label('Model name', layout={'width':'200px'}), text_n2v_name]), ]) display(n2v_parameter)
def __init__(self, callback, value, min_value, max_value, step, description, dict_id='', description_width='150px', layout_width='300px'): def on_value_change(change): callback({self._dict_id: change['new']}) self._dict_id = dict_id self._text_box = ipw.BoundedFloatText( value=value, min=min_value, max=max_value, step=step, description=description, continuous_update=False, style={'description_width': description_width}, layout={'width': layout_width}, disabled=False) self._text_box.observe(on_value_change, names='value')