Python ipywidgets.HBox() Examples
The following are 30
code examples of ipywidgets.HBox().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
ipywidgets
, or try the search function
.
Example #1
Source File: atlas.py From ssbio with MIT License | 7 votes |
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
Example #2
Source File: pylab.py From ipyvolume with MIT License | 6 votes |
def controls_light(return_widget=False): fig = gcf() ambient_coefficient = ipywidgets.FloatSlider( min=0, max=1, step=0.001, value=fig.ambient_coefficient, description="ambient" ) diffuse_coefficient = ipywidgets.FloatSlider( min=0, max=1, step=0.001, value=fig.diffuse_coefficient, description="diffuse" ) specular_coefficient = ipywidgets.FloatSlider( min=0, max=1, step=0.001, value=fig.specular_coefficient, description="specular" ) specular_exponent = ipywidgets.FloatSlider( min=0, max=10, step=0.001, value=fig.specular_exponent, description="specular exp" ) ipywidgets.jslink((fig, 'ambient_coefficient'), (ambient_coefficient, 'value')) ipywidgets.jslink((fig, 'diffuse_coefficient'), (diffuse_coefficient, 'value')) ipywidgets.jslink((fig, 'specular_coefficient'), (specular_coefficient, 'value')) ipywidgets.jslink((fig, 'specular_exponent'), (specular_exponent, 'value')) widgets_bottom = [ ipywidgets.HBox([ambient_coefficient, diffuse_coefficient]), ipywidgets.HBox([specular_coefficient, specular_exponent]), ] current.container.children += tuple(widgets_bottom) if return_widget: return widgets_bottom
Example #3
Source File: ABuWGPSBase.py From abu with GNU General Public License v3.0 | 6 votes |
def _init_widget(self): """构建内置的卖出策略可视化组件,构造出self.factor_box""" from ..WidgetBu.ABuWGPickStock import PSPriceWidget, PSRegressAngWidget from ..WidgetBu.ABuWGPickStock import PSShiftDistanceWidget, PSNTopWidget self.ps_array = [] self.ps_array.append(PSPriceWidget(self)) self.ps_array.append(PSRegressAngWidget(self)) self.ps_array.append(PSShiftDistanceWidget(self)) self.ps_array.append(PSNTopWidget(self)) # ps() call用widget组list children = [ps() for ps in self.ps_array] if self.scroll_factor_box: self.factor_box = widgets.Box(children=children, layout=self.factor_layout) else: # 一行显示两个,3个为一组,组装sub_children_group序列, sub_children_group = self._sub_children(children, len(children) / self._sub_children_group_cnt) sub_children_box = [widgets.HBox(sub_children) for sub_children in sub_children_group] self.factor_box = widgets.VBox(sub_children_box) # 买入因子是特殊的存在,都需要买入因子的全局数据 self.buy_factor_manger = None
Example #4
Source File: dashboard.py From qiskit-ibmq-provider with Apache License 2.0 | 6 votes |
def __init__(self): """IQXDashboard constructor.""" super().__init__() # A list of job widgets. Each represents a job and has 5 children: # close button, Job ID, backend, status, and estimated start time. self.jobs = [] # type: List self._init_subscriber() self.dashboard = None # type: Optional[AccordionWithThread] # Backend dictionary. The keys are the backend names and the values # are named tuples of ``IBMQBackend`` instances and a list of provider names. self.backend_dict = None # type: Optional[Dict[str, BackendWithProviders]] # Jobs tab on the dashboard. self.job_viewer = None # type: Optional[wid.VBox] self._clear_jobs_button = make_clear_button(self) # type: wid.GridBox self._jobs_labels = make_labels() # type: wid.HBox self.refresh_jobs_board()
Example #5
Source File: ABuWGBFBase.py From abu with GNU General Public License v3.0 | 6 votes |
def _init_widget(self): """构建内置的买入策略可视化组件,构造出self.factor_box""" from ..WidgetBu.ABuWGBuyFactor import BuyDMWidget, BuyXDWidget, BuyWDWidget from ..WidgetBu.ABuWGBuyFactor import BuySDWidget, BuyWMWidget, BuyDUWidget self.bf_array = [] self.bf_array.append(BuyDMWidget(self)) self.bf_array.append(BuyXDWidget(self)) self.bf_array.append(BuyWDWidget(self)) self.bf_array.append(BuySDWidget(self)) self.bf_array.append(BuyWMWidget(self)) self.bf_array.append(BuyDUWidget(self)) # bf() call用widget组list children = [bf() for bf in self.bf_array] if self.scroll_factor_box: self.factor_box = widgets.Box(children=children, layout=self.factor_layout) else: # 一行显示两个,n个为一组,组装sub_children_group序列, sub_children_group = self._sub_children(children, len(children) / self._sub_children_group_cnt) sub_children_box = [widgets.HBox(sub_children) for sub_children in sub_children_group] self.factor_box = widgets.VBox(sub_children_box)
Example #6
Source File: combine.py From jupyter-innotater with MIT License | 6 votes |
def add_row(self): newchildren = [] for c in self.childinnotationconfigs: if isinstance(c, tuple) or isinstance(c, list): kwargs = {} if len(c) <= 2 else c[2] kwargs['repeat_index'] = self.rows_count if 'name' in kwargs: kwargs['name'] = '{}_{}'.format(kwargs['name'], self.rows_count) newchildren.append(c[0](c[1], **kwargs)) else: newchildren.append(c(self.data)) self.rows_count += 1 self.children_changed(newchildren) self.get_widget().children = tuple(list(self.get_widget().children)+[HBox([c.get_widget() for c in newchildren])]) self.childinnotations.extend(newchildren) if self.max_repeats == self.rows_count: self.addbtn.disabled = True
Example #7
Source File: progressbar.py From QuLab with MIT License | 6 votes |
def __init__(self, *, max=10, description='Progressing', loop=None, hiden=False): self.start_ts = monotonic() self.avg = 0 self._avg_update_ts = self.start_ts self._ts = self.start_ts self._xput = deque(maxlen=self.sma_window) self._ProgressWidget = widgets.IntProgress(value=0, min=0, max=max, step=1, description=description, bar_style='') self._elapsedTimeLabel = widgets.Label(value='Used time: 00:00:00') self._etaTimeLabel = widgets.Label(value='Remaining time: --:--:--') self.ui = widgets.HBox( [self._ProgressWidget, self._elapsedTimeLabel, self._etaTimeLabel]) self.loop = asyncio.get_event_loop() if loop is None else loop self._update_loop = None self._displayed = False if not hiden else True
Example #8
Source File: widgets.py From tyssue with GNU General Public License v3.0 | 6 votes |
def parameter_settings(eptm): specs = eptm.specs elements = [] for element in ["edge", "vert", "face"]: if element not in specs: continue spec = specs[element] fts = [] for param, val in spec.items(): def update_param(change): specs[element][param] = change["new"] print(change) print("{} {} changed to {}".format(element, param, change["new"])) w = ipw.FloatText(val, description=param) w.observe(update_param, names="value") fts.append(w) elements.append(ipw.VBox(fts)) return ipw.HBox(elements)
Example #9
Source File: visualization.py From minian with GNU General Public License v3.0 | 6 votes |
def _widgets(self): dfrange = self.varr.range('frame') w_frame = iwgt.IntSlider( value=0, min=dfrange[0], max=dfrange[1], continuous_update=False, description="Frame:") w_paly = iwgt.Play( value=0, min=dfrange[0], max=dfrange[1], interval=1000 / self.framerate) iwgt.jslink((w_paly, 'value'), (w_frame, 'value')) iwgt.interactive(self.stream.event, f=w_frame) return iwgt.HBox([w_paly, w_frame])
Example #10
Source File: job_widgets.py From qiskit-ibmq-provider with Apache License 2.0 | 6 votes |
def make_labels() -> widgets.HBox: """Makes the labels widget. Returns: The labels widget. """ labels0 = widgets.HTML(value="<h5>Job ID</h5>", layout=widgets.Layout(width='190px')) labels1 = widgets.HTML(value='<h5>Backend</h5>', layout=widgets.Layout(width='165px')) labels2 = widgets.HTML(value='<h5>Status</h5>', layout=widgets.Layout(width='125px')) labels3 = widgets.HTML(value='<h5>Est. Start Time</h5>', layout=widgets.Layout(width='100px')) labels = widgets.HBox(children=[labels0, labels1, labels2, labels3], layout=widgets.Layout(width='700px', margin='0px 0px 0px 35px')) return labels
Example #11
Source File: ipython.py From OpenModes with GNU General Public License v3.0 | 6 votes |
def progress_iterator(orig_iterator, description): """Wrap an iterator so that a progress bar is displayed Parameters ---------- orig_iterator: iterator The original iterator. It must implement the __len__ operation so that its length can be calculated in advance. description: string Description will give a text label for the bar. """ progress_widget = FloatProgress(min=0, max=len(orig_iterator)-1) widget = HBox([Label(description), progress_widget]) display(widget) for count, val in enumerate(orig_iterator): yield val progress_widget.value = count
Example #12
Source File: TSEBIPythonInterface.py From pyTSEB with GNU General Public License v3.0 | 6 votes |
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')
Example #13
Source File: ABuWGPosBase.py From abu with GNU General Public License v3.0 | 6 votes |
def _init_widget(self): """构建内置的仓位资金管理可视化组件,构造出self.factor_box""" from ..WidgetBu.ABuWGPosition import AtrPosWidget, KellyPosWidget, PtPosition self.pos_array = [] self.pos_array.append(AtrPosWidget(self)) self.pos_array.append(KellyPosWidget(self)) self.pos_array.append(PtPosition(self)) # ps() call用widget组list children = [pos() for pos in self.pos_array] if self.scroll_factor_box: self.factor_box = widgets.Box(children=children, layout=self.factor_layout) else: # 一行显示两个,n个为一组,组装sub_children_group序列, sub_children_group = self._sub_children(children, len(children) / self._sub_children_group_cnt) sub_children_box = [widgets.HBox(sub_children) for sub_children in sub_children_group] self.factor_box = widgets.VBox(sub_children_box) # 买入因子是特殊的存在,都需要买入因子的全局数据 self.buy_factor_manger = None
Example #14
Source File: moviemaker.py From ipyvolume with MIT License | 6 votes |
def show(self): box_io = widgets.HBox([self.button_save, self.button_load]) box_control = widgets.HBox([self.button_add, self.button_replace, self.button_remove]) display( widgets.VBox( [ self.button_record, self.select_interpolation, box_io, box_control, self.select_keyframes, self.camera_action_box, self.output, ] ) )
Example #15
Source File: visualization_ply.py From minian with GNU General Public License v3.0 | 6 votes |
def _widgets(self): dfrange = self.varr_hv.range('frame') w_frame = iwgt.IntSlider( value=0, min=dfrange[0], max=dfrange[1], continuous_update=False, description="Frame:") w_paly = iwgt.Play( value=0, min=dfrange[0], max=dfrange[1], interval=1000 / self.framerate) iwgt.jslink((w_paly, 'value'), (w_frame, 'value')) iwgt.interactive(self.stream.event, f=w_frame) return iwgt.HBox([w_paly, w_frame])
Example #16
Source File: job_widgets.py From qiskit-terra with Apache License 2.0 | 6 votes |
def make_labels(): """Makes the labels widget. Returns: widget: The labels widget. """ labels0 = widgets.HTML(value="<h5>Job ID</h5>", layout=widgets.Layout(width='190px')) labels1 = widgets.HTML(value='<h5>Backend</h5>', layout=widgets.Layout(width='145px')) labels2 = widgets.HTML(value='<h5>Status</h5>', layout=widgets.Layout(width='95px')) labels3 = widgets.HTML(value='<h5>Queue</h5>', layout=widgets.Layout(width='70px')) labels4 = widgets.HTML(value='<h5>Message</h5>') labels = widgets.HBox(children=[labels0, labels1, labels2, labels3, labels4], layout=widgets.Layout(width='600px', margin='0px 0px 0px 37px')) return labels
Example #17
Source File: qubit_widget.py From scqubits with BSD 3-Clause "New" or "Revised" License | 6 votes |
def create_widget(callback_func, init_params, image_filename=None): """ Displays ipywidgets for initialization of a QuantumSystem object. Parameters ---------- callback_func: function callback_function depends on all the parameters provided as keys (str) in the parameter_dict, and is called upon changes of values inside the widgets init_params: {str: value, str: value, ...} names and values of initialization parameters image_filename: str, optional file name for circuit image to be displayed alongside the qubit Returns ------- """ widgets = {} box_list = [] for name, value in init_params.items(): label = ipywidgets.Label(value=name) if isinstance(value, float): enter_widget = ipywidgets.FloatText else: enter_widget = ipywidgets.IntText widgets[name] = enter_widget(value=value, description='', disabled=False) box_list.append(ipywidgets.HBox([label, widgets[name]], layout=ipywidgets.Layout(justify_content='flex-end'))) if image_filename: file = open(image_filename, "rb") image = file.read() image_widget = ipywidgets.Image(value=image, format='png', layout=ipywidgets.Layout(width='400px')) ui_widget = ipywidgets.HBox([ipywidgets.VBox(box_list), ipywidgets.VBox([image_widget])]) else: ui_widget = ipywidgets.VBox(box_list) out = ipywidgets.interactive_output(callback_func, widgets) display(ui_widget, out)
Example #18
Source File: ABuWGTLTool.py From abu with GNU General Public License v3.0 | 6 votes |
def __init__(self, tool_set): """初始化技术分析界面""" super(WidgetTLTool, self).__init__(tool_set) rs_box = self.init_rs_ui() jump_box = self.init_jump_ui() pair_speed = self.init_pair_speed_ui() shift_distance = self.init_shift_distance_ui() regress = self.init_regress_ui() golden = self.init_golden_line_ui() skeleton = self.init_skeleton_ui() children = [rs_box, jump_box, pair_speed, shift_distance, regress, golden, skeleton] if self.scroll_factor_box: tl_box = widgets.Box(children, layout=self.scroll_widget_layout) # 需要再套一层VBox,不然外部的tab显示有问题 self.widget = widgets.VBox([tl_box]) else: # 一行显示两个,2个为一组,组装sub_children_group序列, sub_children_group = self._sub_children(children, len(children) / self._sub_children_group_cnt) sub_children_box = [widgets.HBox(sub_children) for sub_children in sub_children_group] self.widget = widgets.VBox(sub_children_box)
Example #19
Source File: TSEBIPythonInterface.py From pyTSEB with GNU General Public License v3.0 | 6 votes |
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')
Example #20
Source File: visualization_ply.py From minian with GNU General Public License v3.0 | 6 votes |
def _widgets(self): dfrange = self.ds.range('frame') w_frame = iwgt.IntSlider( value=0, min=dfrange[0], max=dfrange[1], continuous_update=False, description="Frame:") w_paly = iwgt.Play( value=0, min=dfrange[0], max=dfrange[1], interval=1000 / self.framerate) iwgt.jslink((w_paly, 'value'), (w_frame, 'value')) iwgt.interactive(self.stream.event, f=w_frame) return iwgt.HBox([w_paly, w_frame])
Example #21
Source File: pointcloud.py From AlignNet-3D with BSD 3-Clause "New" or "Revised" License | 6 votes |
def show_mesh(mesh_id, cat='car', aligned=True): print(mesh_id) mesh_fname = f'/globalwork/gross/ModelNet/ModelNet40{"Aligned" if aligned else ""}/{cat}/train/{cat}_{str(mesh_id).zfill(4)}.off' if not os.path.isfile(mesh_fname): mesh_fname = f'/globalwork/gross/ModelNet/ModelNet40{"Aligned" if aligned else ""}/{cat}/test/{cat}_{str(mesh_id).zfill(4)}.off' mesh = get_mesh(mesh_fname) mesh.apply_scale(3.) def on_button_next(b): clear_output() show_mesh(mesh_id + 1, cat=cat, aligned=aligned) def on_button_prev(b): clear_output() show_mesh(max(mesh_id - 1, 1), cat=cat, aligned=aligned) button_next = ipywidgets.Button(description="Next") button_prev = ipywidgets.Button(description="Prev") display(ipywidgets.HBox([button_prev, button_next])) button_next.on_click(on_button_next) button_prev.on_click(on_button_prev) scene = trimesh.Scene(mesh.mesh) viewer = scene.show(viewer='notebook') display(viewer) return scene, viewer
Example #22
Source File: explorer.py From scqubits with BSD 3-Clause "New" or "Revised" License | 5 votes |
def interact(self): """Drives the interactive display of the plot explorer panels""" param_min = self.param_vals[0] param_max = self.param_vals[-1] param_step = self.param_vals[1] - self.param_vals[0] qbt_indices = [index for (index, subsystem) in self.sweep.qbt_subsys_list] osc_indices = [index for (index, subsystem) in self.sweep.osc_subsys_list] param_slider = ipywidgets.FloatSlider(min=param_min, max=param_max, step=param_step, description=self.param_name, continuous_update=False) photon_slider = ipywidgets.IntSlider(value=1, min=1, max=4, description='photon number') initial_slider = ipywidgets.IntSlider(value=0, min=0, max=self.evals_count, description='initial state index') final_slider = ipywidgets.IntSlider(value=1, min=1, max=self.evals_count, description='final state index') qbt_dropdown = ipywidgets.Dropdown(options=qbt_indices, description='qubit subsys') osc_dropdown = ipywidgets.Dropdown(options=osc_indices, description='oscillator subsys') def update_min_final_index(*args): final_slider.min = initial_slider.value + 1 initial_slider.observe(update_min_final_index, 'value') out = ipywidgets.interactive_output(self.plot_explorer_panels, {'param_val': param_slider, 'photonnumber': photon_slider, 'initial_index': initial_slider, 'final_index': final_slider, 'qbt_index': qbt_dropdown, 'osc_index': osc_dropdown }) left_box = ipywidgets.VBox([param_slider]) mid_box = ipywidgets.VBox([initial_slider, final_slider, photon_slider]) right_box = ipywidgets.VBox([qbt_dropdown, osc_dropdown]) user_interface = ipywidgets.HBox([left_box, mid_box, right_box]) display(user_interface, out)
Example #23
Source File: visualization.py From minian with GNU General Public License v3.0 | 5 votes |
def _widgets(self): sel_anm = iwgt.Dropdown(options=self.ls_anm, description='Animal:') sel_ss = iwgt.Dropdown(options=self.ls_ss, description='Session:') bt_mask0 = iwgt.Button(description="Update Template") bt_mask = iwgt.Button(description="Update Target") bt_mask0.on_click(self._save_mask0) bt_mask.on_click(self._save_mask) iwgt.interactive(self.str_sel.event, anm=sel_anm, ss=sel_ss) return iwgt.HBox([sel_anm, sel_ss, bt_mask0, bt_mask])
Example #24
Source File: progress.py From pywr with GNU General Public License v3.0 | 5 votes |
def reset(self): from ipywidgets import FloatProgress, HBox, Label, Layout from IPython.display import display super(JupyterProgressRecorder, self).reset() self.progress_bar = FloatProgress(min=0, max=100, description='Running:') self.label = Label("", layout=Layout(width='100%')) self.box = HBox([self.progress_bar, self.label]) display(self.box)
Example #25
Source File: pubsub.py From jupyter-ros with BSD 3-Clause "New" or "Revised" License | 5 votes |
def subscribe(topic, msg_type, callback): """ Subscribes to a specific topic in another thread, but redirects output! @param topic The topic @param msg_type The message type @param callback The callback @return Jupyter output widget """ if subscriber_registry.get(topic): print("Removing previous callback, only one redirection possible right now", file=sys.stderr) subscriber_registry[topic].unregister() out = widgets.Output(layout={'border': '1px solid gray'}) subscriber_registry[topic] = rospy.Subscriber(topic, msg_type, callback) output_registry[topic] = out btn = widgets.Button(description='Stop') def stop_start_subscriber(x): if output_registry.get(topic) is not None: subscriber_registry[topic].unregister() del output_registry[topic] btn.description = 'Start' else: output_registry[topic] = out subscriber_registry[topic] = rospy.Subscriber(topic, msg_type, callback) btn.description = 'Stop' btn.on_click(stop_start_subscriber) btns = widgets.HBox((btn, )) vbox = widgets.VBox((btns, out)) return vbox
Example #26
Source File: plot.py From meshplot with GNU General Public License v3.0 | 5 votes |
def __init__(self, data, view, s): if data == None: self.rows = [] self.hboxes = [] else: self.rows = data.rows if s[0] != 1 or s[1] != 1: if data == None: # Intialize subplot array cnt = 0 for r in range(s[0]): row = [] for c in range(s[1]): row.append(Output()) cnt += 1 self.rows.append(row) for r in self.rows: hbox = HBox(r) if rendertype == "JUPYTER": display(hbox) self.hboxes.append(hbox) out = self.rows[int(s[2]/s[1])][s[2]%s[1]] if rendertype == "JUPYTER": with out: display(view._renderer) self.rows[int(s[2]/s[1])][s[2]%s[1]] = view
Example #27
Source File: ri_client.py From qkit with GNU General Public License v2.0 | 5 votes |
def control_panel(ric = None): from ipywidgets import Button, HTML,HBox,Accordion from IPython.core.display import display def fmt(inp): if inp is None: return "--" elif type(inp) is float: return "{:.4g}".format(inp) else: return str(inp) if ric is None: ric = qkit.ric def update_instrument_params(b): insdict = ric.get_all_instrument_params() for ins in sorted(insdict): if not ins in b.accordions: b.accordions[ins] = Accordion() table = "<table style='line-height:180%'>" # <tr style='font-weight:bold'><td> Parameter </td><td>Value</td></tr> for p in sorted(insdict[ins]): table += "<tr><td style='text-align:right;padding-right:10px'>" + str(p) + "</td><td>" + fmt(insdict[ins][p][0]) + insdict[ins][p][ 1] + "</td></tr>" table += """</table>""" b.accordions[ins].children = [HTML(table)] b.accordions[ins].set_title(0, ins) for child in b.accordions.keys(): if child not in insdict: del b.accordions[child] b.hbox.children = b.accordions.values() update_button = Button(description="Update") update_button.on_click(update_instrument_params) update_button.accordions = {} update_button.hbox = HBox() stop_button = Button(description="Stop measurement") stop_button.on_click(lambda b: qkit.ric.stop_measure()) stop_button.button_style = "danger" update_instrument_params(update_button) display(HBox([update_button,stop_button]),update_button.hbox)
Example #28
Source File: peakfinder2D_gui.py From pyxem with GNU General Public License v3.0 | 5 votes |
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)
Example #29
Source File: jobs_widget.py From qiskit-ibmq-provider with Apache License 2.0 | 5 votes |
def jobs_tab(backend: Union[IBMQBackend, FakeBackend]) -> wid.HBox: """Construct a widget containing job information for an input backend. Args: backend: Input backend. Returns: An widget containing job summary. """ title = wid.HTML('<h4>Click graph to display jobs</h4>') table = wid.HTML('', layout=wid.Layout(max_height='500px', height='500px', width='100%', overflow='hidden scroll',)) sun_wid = _job_summary(backend) sun_wid._table = table sun_wid._title = title left = wid.Box(children=[sun_wid], layout=wid.Layout(width='40%', overflow='hidden hidden')) right = wid.VBox(children=[title, table], layout=wid.Layout(width='60%', overflow='hidden hidden')) out = wid.HBox(children=[left, right], layout=wid.Layout(max_height='500px', margin='10px')) return out
Example #30
Source File: peakfinder2D_gui.py From pyxem with GNU General Public License v3.0 | 5 votes |
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