Python ipywidgets.VBox() Examples

The following are 30 code examples of ipywidgets.VBox(). 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 vote down vote up
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: ABuWGTLTool.py    From abu with GNU General Public License v3.0 6 votes vote down vote up
def init_rs_ui(self):
        """阻力支撑分析ui"""

        with self._init_tip_label_with_step_x(
                self._rs_line_analyse, u'支撑阻力线分析', with_step_x=False) as (widget_list, _):
            self.rs_mode = widgets.RadioButtons(
                options={u'只分析支撑线': 0, u'只分析阻力线': 1, u'支撑线和阻力线': 2},
                value=0,
                description=u'分析模式:',
                disabled=False
            )
            widget_list.append(self.rs_mode)
            self.only_last = widgets.RadioButtons(
                options={u'最近的阻力线和支撑线': True, u'所有的阻力线和支撑线': False},
                value=True,
                description=u'最近的阻力线和支撑线',
                disabled=False
            )
            widget_list.append(self.only_last)
        return widgets.VBox(widget_list,  # border='solid 1px',
                            layout=self.tool_layout) 
Example #3
Source File: dashboard.py    From qiskit-ibmq-provider with Apache License 2.0 6 votes vote down vote up
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 #4
Source File: TSEBIPythonInterface.py    From pyTSEB with GNU General Public License v3.0 6 votes vote down vote up
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 #5
Source File: progress_bars.py    From pandarallel with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def __init__(self, maxs):
        """Initialization.
        Positional argument:
        maxs - List containing the max value of each progress bar
        """
        from IPython.display import display
        from ipywidgets import HBox, VBox, IntProgress, Label

        self.__bars = [
            HBox(
                [
                    IntProgress(0, 0, max, description="{:.2f}%".format(0)),
                    Label("{} / {}".format(0, max)),
                ]
            )
            for max in maxs
        ]

        display(VBox(self.__bars)) 
Example #6
Source File: ABuWGTLTool.py    From abu with GNU General Public License v3.0 6 votes vote down vote up
def init_shift_distance_ui(self):
        """位移路程比ui"""

        with self._init_tip_label_with_step_x(
                self._shift_distance_analyse, u'位移路程分析') as (widget_list, step_x):
            self.shift_distance_step_x = step_x
            self.shift_distance_mode = widgets.RadioButtons(
                options={u'序列最后的元素做为路程基础': 0, u'极限值做为路程的计算基础': 1,
                         u'序列sum+极值做为路程计算基础': 2},
                value=0,
                description=u'路程模式:',
                disabled=False
            )
            widget_list.append(self.shift_distance_mode)
        return widgets.VBox(widget_list,
                            # border='solid 1px',
                            layout=self.tool_layout) 
Example #7
Source File: moviemaker.py    From ipyvolume with MIT License 6 votes vote down vote up
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 #8
Source File: ABuWGPosBase.py    From abu with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, wg_manager):
        super(WidgetPositionBase, self).__init__(wg_manager)
        self.add = widgets.Button(description=u'选定为全局资金管理策略', layout=widgets.Layout(width='98%'),
                                  button_style='info')
        # 选定全局资金管理略指令按钮
        self.add.on_click(self.add_position)
        # 运行混入的BFSubscriberMixin中ui初始化
        self.subscriber_ui([u'点击\'已添加的买入策略\'框中的买入策略', u'资金管理做为买入策略的资金管理策略'])
        # 买入策略框点击行为:将本卖出策略加到对应的买入策略做为附属
        self.buy_factors.observe(self.add_position_to_buy_factor, names='value')
        self.accordion.set_title(0, u'添加为指定买入因子的资金管理策略')
        accordion_shut(self.accordion)
        self.add_box = widgets.VBox([self.add, self.accordion])

        # 具体子策略构建
        self._init_widget() 
Example #9
Source File: ABuWGPosBase.py    From abu with GNU General Public License v3.0 6 votes vote down vote up
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 #10
Source File: TSEBIPythonInterface.py    From pyTSEB with GNU General Public License v3.0 6 votes vote down vote up
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 #11
Source File: qubit_widget.py    From scqubits with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 #12
Source File: ABuWGTLTool.py    From abu with GNU General Public License v3.0 6 votes vote down vote up
def init_skeleton_ui(self):
        """价格骨架ui"""
        with self._init_tip_label_with_step_x(
                self._skeleton_analyse, u'价格骨架分析') as (widget_list, step_x):
            self.skeleton_step_x = step_x
            self.skeleton_mode = widgets.RadioButtons(
                options={u'骨架通道点位值': 200, u'三角骨架点位值': 100, u'最小值骨架点位值': 0,
                         u'最大值骨架点位值': 1, u'平均值骨架点位值': 2, u'中位数骨架点位值': 3,
                         u'最后元素骨架点位值': 4},
                value=200,
                description=u'骨架模式:',
                disabled=False
            )
            widget_list.append(self.skeleton_mode)
        return widgets.VBox(widget_list,
                            # border='solid 1px',
                            layout=self.tool_layout) 
Example #13
Source File: ABuWGPosBase.py    From abu with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        super(PosWGManager, self).__init__()

        position_label = widgets.Label(u'无选定时默认资管为:atr资金仓位管理策略',
                                       layout=widgets.Layout(width='300px'))

        self.widget = widgets.VBox([self.factor_box, position_label, self.selected_factors]) 
Example #14
Source File: plot_bqplot.py    From lantern with Apache License 2.0 5 votes vote down vote up
def show(self, title='', xlabel='', ylabel='', xaxis=True, yaxis=True, xticks=True, yticks=True, legend=True, grid=True, **kwargs):
        # require all data to be present before plotting
        x = Axis(title=xlabel, scale=self._x_sc)
        y = Axis(title=ylabel, scale=self._y_sc, orientation='vertical')
        fig = Figure(axes=[x, y], marks=self._marks, title=title, legend_location='right', interactions=BrushIntervalSelector())

        display(VBox([fig, Toolbar(figure=fig)])) 
Example #15
Source File: ABuWGBRun.py    From abu with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        """构建回测需要的各个组件形成tab"""
        self.tt = WidgetRunTT()
        self.sc = WidgetSymbolChoice()
        self.bf = BuyFactorWGManager()

        self.sf = SellFactorWGManager()
        # 卖出策略管理注册买入策略接收改变
        self.sf.register(self.bf)

        self.ps = PickStockWGManager()
        # 选股策略管理注册买入策略接收改变
        self.ps.register(self.bf)

        self.pos = PosWGManager()
        # 资金管理注册买入策略接收改变
        self.pos.register(self.bf)

        # 构造裁判界面
        self.ump = WidgetUmp()

        sub_widget_tab = widgets.Tab()
        sub_widget_tab.children = [self.tt.widget, self.sc.widget, self.bf.widget, self.sf.widget, self.ps.widget,
                                   self.pos.widget, self.ump.widget]
        for ind, name in enumerate([u'基本', u'股池', u'买策', u'卖策', u'选股', u'资管', u'裁判']):
            sub_widget_tab.set_title(ind, name)

        self.run_loop_bt = widgets.Button(description=u'开始回测', layout=widgets.Layout(width='98%'),
                                          button_style='danger')
        self.run_loop_bt.on_click(self.run_loop_back)
        self.widget = widgets.VBox([sub_widget_tab, self.run_loop_bt]) 
Example #16
Source File: ABuWGUmp.py    From abu with GNU General Public License v3.0 5 votes vote down vote up
def _init_manager_ui(self):
        """裁判数据管理界面初始化"""
        description = widgets.Textarea(
            value=u'删除选择的裁判本地数据:\n'
                  u'删除所选择的已训练好的本地裁判数据,谨慎操作!\n'
                  u'分享选择的裁判:\n'
                  u'将训练好的裁判数据分享到交易社区,供其他交易者使用\n'
                  u'下载更多的裁判:\n'
                  u'从交易社区,下载更多训练好的裁判数据\n',

            disabled=False,
            layout=widgets.Layout(height='150px')
        )

        self.manager_umps = widgets.Select(
            options=[],
            description=u'本地裁判:',
            disabled=False,
            layout=widgets.Layout(width='100%', align_items='stretch')
        )
        self.load_train_ump(self.manager_umps)
        delete_bt = widgets.Button(description=u'删除选择的裁判本地数据', layout=widgets.Layout(width='98%'),
                                   button_style='warning')
        delete_bt.on_click(self._do_delete_ump)

        share_bt = widgets.Button(description=u'分享选择的裁判', layout=widgets.Layout(width='98%'),
                                  button_style='info')
        share_bt.on_click(permission_denied)
        down_bt = widgets.Button(description=u'下载更多的裁判', layout=widgets.Layout(width='98%'),
                                 button_style='info')
        down_bt.on_click(permission_denied)

        return widgets.VBox([description, self.manager_umps, delete_bt, share_bt, down_bt]) 
Example #17
Source File: pubsub.py    From jupyter-ros with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 #18
Source File: ABuWGSFBase.py    From abu with GNU General Public License v3.0 5 votes vote down vote up
def _init_widget(self):
        """构建内置的卖出策略可视化组件,构造出self.factor_box"""

        from ..WidgetBu.ABuWGSellFactor import SellXDWidget, SellAtrNStopWidget, SellCloseAtrNWidget
        from ..WidgetBu.ABuWGSellFactor import SellPreAtrNWidget, SellDMWidget, SellNDWidget

        self.sf_array = []
        self.sf_array.append(SellAtrNStopWidget(self))
        self.sf_array.append(SellCloseAtrNWidget(self))
        self.sf_array.append(SellPreAtrNWidget(self))
        self.sf_array.append(SellXDWidget(self))
        self.sf_array.append(SellDMWidget(self))
        self.sf_array.append(SellNDWidget(self))

        # sf() call用widget组list
        children = [sf() for sf in self.sf_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 #19
Source File: ABuWGSFBase.py    From abu with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, wg_manager):
        super(WidgetFactorSellBase, self).__init__(wg_manager)

        if wg_manager.add_button_style == 'grid':
            add_cb = widgets.Button(description=u'添加为寻找卖出策略最优参数组合', layout=widgets.Layout(width='98%'),
                                    button_style='info')
            add_cb.on_click(self.add_sell_factor)

            add_dp = widgets.Button(description=u'添加为寻找独立卖出策略最佳组合', layout=widgets.Layout(width='98%'),
                                    button_style='warning')
            add_dp.on_click(self.add_sell_factor_grid)

            self.add = widgets.VBox([add_cb, add_dp])
        else:
            self.add = widgets.Button(description=u'添加为全局卖出策略', layout=widgets.Layout(width='98%'),
                                      button_style='info')
            # 添加全局卖出策略指令按钮
            self.add.on_click(self.add_sell_factor)

        if self.wg_manager.show_add_buy:
            # 运行混入的BFSubscriberMixin中ui初始化
            self.subscriber_ui([u'点击\'已添加的买入策略\'框中的买入策略', u'将卖出策略做为买入策略的附属卖出策略'])
            # 买入策略框点击行为:将本卖出策略加到对应的买入策略做为附属
            self.buy_factors.observe(self.add_sell_factor_to_buy_factor, names='value')
            self.accordion.set_title(0, u'添加为指定买入因子的卖出策略')
            accordion_shut(self.accordion)
            self.add_box = widgets.VBox([self.add, self.accordion])
        else:
            self.add_box = self.add

        self._init_widget() 
Example #20
Source File: ABuWGUmp.py    From abu with GNU General Public License v3.0 5 votes vote down vote up
def _init_train_ui(self):
        """裁判特征训练面初始化"""
        description = widgets.Textarea(
            value=u'裁判特征训练:\n'
                  u'通过在\'裁判特征采集\'选中\'回测过程生成交易特征\'可在回测完成后保存当此回测结果\n'
                  u'所有回测的结果将显示在下面的\'备选回测:\'框中\n'
                  u'通过\'开始训练裁判\'进行指定的回测裁判训练,训练后的裁判在\'裁判预测拦截\'下可进行选择,选中的裁判将在对应的'
                  u'回测中生效,即开始在回测中对交易进行预测拦截等智能交易干涉行为',

            disabled=False,
            layout=widgets.Layout(height='150px')
        )

        self.abu_result = widgets.Select(
            options=[],
            description=u'备选回测:',
            disabled=False,
            layout=widgets.Layout(width='100%', align_items='stretch')
        )
        self.load_abu_result()

        train_bt = widgets.Button(description=u'开始训练裁判', layout=widgets.Layout(width='98%'),
                                  button_style='info')
        train_bt.on_click(self._do_train)
        delete_bt = widgets.Button(description=u'删除选择的备选回测本地数据', layout=widgets.Layout(width='98%'),
                                   button_style='warning')
        delete_bt.on_click(self._do_delete_abu_result)

        return widgets.VBox([description, self.abu_result, train_bt, delete_bt]) 
Example #21
Source File: visuals.py    From python-esppy with Apache License 2.0 5 votes vote down vote up
def __init__(self,visuals,datasource,**kwargs):
        Options.__init__(self,**kwargs)
        widgets.VBox.__init__(self,layout=widgets.Layout(width=self.getOpt("width","95%"),height=self.getOpt("height","95%"),border=visuals.getOpt("border","0"),padding=visuals.getOpt("padding","10px"),margin=visuals.getOpt("margin","10px")))
        self._visuals = visuals
        self._datasource = datasource
        self._figure = None
        self._data = None
        self._layout = None
        self._controls = None
        self._title = widgets.HTML(layout=widgets.Layout(overflow="hidden"))
        self._banner = widgets.VBox([self._title]) 
Example #22
Source File: dashboard.py    From qiskit-ibmq-provider with Apache License 2.0 5 votes vote down vote up
def _add_device_to_list(backend: BackendWithProviders,
                        device_list: wid.VBox) -> None:
    """Add the backend to the device list widget.

    Args:
        backend: Backend to add.
        device_list: Widget showing the devices.
    """
    device_pane = make_backend_widget(backend)
    device_list.children = list(device_list.children) + [device_pane] 
Example #23
Source File: progress_bar.py    From threeML with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _setup(self):

        # Setup the widget, which is a bar between 0 and 100

        self._bar = FloatProgress(min=0, max=100)

        # Set explicitly the bar to 0

        self._bar.value = 0

        # Setup also an HTML label (which will contain the progress, the elapsed time and the foreseen
        # completion time)

        self._title_cell = HTML()

        if self._title is not None:

            self._title_cell.value = "%s : " % self._title

        self._label = HTML()
        self._vbox = VBox(children=[self._title_cell, self._label, self._bar])

        # Display everything

        display(self._vbox)

        self._animate(0) 
Example #24
Source File: visualization.py    From minian with GNU General Public License v3.0 5 votes vote down vote up
def _widgets(self):
        dfrange = [0, self._f]
        w_frame = iwgt.IntSlider(
            value=0,
            min=dfrange[0],
            max=dfrange[1],
            continuous_update=False,
            description="Frame:",
            layout=iwgt.Layout(width='50%'))
        w_play = iwgt.Play(
            value=0,
            min=dfrange[0],
            max=dfrange[1],
            interval=1000 / self.framerate)
        iwgt.jslink((w_play, 'value'), (w_frame, 'value'))
        iwgt.interactive(self.strm_f.event, x=w_frame)
        uidrange = [0, self._u]
        w_select = iwgt.IntRangeSlider(
            value=self._cur_sel,
            min=uidrange[0],
            max=uidrange[1],
            continuous_update=False,
            description="Unit ID:",
            layout=iwgt.Layout(width='50%'))
        w_select.observe(self._set_sel, names='value')
        w_update = iwgt.Button(description="Update")
        w_update.on_click(self._update_plot)
        w_update_mov = iwgt.Checkbox(
            value=self._update_mov, description="Update Movies")
        w_update_mov.observe(self._set_update, names='value')
        w_overlay = iwgt.Checkbox(value=self._overlay, description="Overlay")
        w_overlay.observe(self._set_overlay, names='value')
        return iwgt.VBox([
            iwgt.HBox([w_frame, w_play, w_update_mov]),
            iwgt.HBox([w_select, w_update, w_overlay])
        ]) 
Example #25
Source File: interfaces.py    From notebook-molecular-visualization with Apache License 2.0 5 votes vote down vote up
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">&nbsp;</span>'  # empty space
                '<span class="nbv-table-header nbv-width-lg">'
                '          Run calculations...</span>'
                '<span class="nbv-table-header nbv-width-med"> &nbsp;</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">&nbsp;</span>'  # empty space
                '<span class="nbv-table-header nbv-width-lg">'
                '          Run calculations...</span>'
                '<span class="nbv-table-header nbv-width-med"> &nbsp;</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) 
Example #26
Source File: notebook_integration.py    From adaptive with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def live_info(runner, *, update_interval=0.5):
    """Display live information about the runner.

    Returns an interactive ipywidget that can be
    visualized in a Jupyter notebook.
    """
    if not _holoviews_enabled:
        raise RuntimeError(
            "Live plotting is not enabled; did you run "
            "'adaptive.notebook_extension()'?"
        )

    import ipywidgets
    from IPython.display import display

    status = ipywidgets.HTML(value=_info_html(runner))

    cancel = ipywidgets.Button(
        description="cancel runner", layout=ipywidgets.Layout(width="100px")
    )
    cancel.on_click(lambda _: runner.cancel())

    async def update():
        while not runner.task.done():
            await asyncio.sleep(update_interval)

            if should_update(status):
                status.value = _info_html(runner)
            else:
                await asyncio.sleep(0.05)

        status.value = _info_html(runner)
        cancel.layout.display = "none"

    runner.ioloop.create_task(update())

    display(ipywidgets.VBox((status, cancel))) 
Example #27
Source File: ontologysearch.py    From tellurium with Apache License 2.0 5 votes vote down vote up
def __init__(self):
        self.ch = bioservices.ChEBI()
        self.kegg = bioservices.KEGG()

        self.wOntologySelect = w.Dropdown(description='Ontology:', options=['ChEBI', 'KEGG.Reaction'])
        self.wSearchTerm = w.Text(description='Search Term:', value="glucose")
        self.wSearchTerm.on_submit(self.search)
        self.wSearchButton = w.Button(description='Search')
        self.wSearchButton.on_click(self.search)

        self.wResultsSelect = w.Select(description='Results:', width='100%')
        self.wResultsSelect.on_trait_change(self.selectedTerm)
        self.wResultsURL = w.Textarea(description='URL:', width='100%')
        self.wResults = w.VBox(children=[
                self.wResultsSelect,
                self.wResultsURL
        ], width='100%')
        for ch in self.wResults.children:
            ch.font_family = 'monospace'
            ch.color = '#AAAAAA'
            ch.background_color = 'black'

        # <Container>
        self.wContainer = w.VBox([
            self.wOntologySelect,
            self.wSearchTerm,
            self.wSearchButton,
            self.wResults
        ])

        # display the container
        display(self.wContainer)
        self.init_display() 
Example #28
Source File: jobs_widget.py    From qiskit-ibmq-provider with Apache License 2.0 5 votes vote down vote up
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 #29
Source File: provider_buttons.py    From qiskit-ibmq-provider with Apache License 2.0 5 votes vote down vote up
def provider_buttons(providers: List[str]) -> wid.VBox:
    """Generate a collection of provider buttons for a backend.

    When one of these buttons is clicked, the code to get the particular
    provider is copied to the clipboard.

    Args:
        providers: A list of provider names.

    Returns:
        A widget with provider buttons.
    """
    vbox_buttons = []
    for pro in providers:
        button = wid.Box(children=[vue.Btn(color='#f5f5f5', small=True,
                                           children=[pro],
                                           style_="font-family: Arial,"
                                                  "sans-serif; font-size:10px;")],
                         layout=wid.Layout(margin="0px 0px 2px 0px",
                                           width='350px'))

        button.children[0].on_event('click', _copy_text)
        vbox_buttons.append(button)

    return wid.VBox(children=vbox_buttons,
                    layout=wid.Layout(width='350px',
                                      max_width='350px')) 
Example #30
Source File: ABuWGUmp.py    From abu with GNU General Public License v3.0 5 votes vote down vote up
def _init_feature_ui(self):
        """裁判特征采集界面初始化"""
        ml_feature_description = widgets.Textarea(
            value=u'裁判特征采集\n'
                  u'裁判是建立在机器学习技术基础上的,所以必然会涉及到特征,abu量化系统支持在回测过程中生成特征数据,切分训练测试集,'
                  u'甚至成交买单快照图片,通过打开下面的开关即可在生成最终的输出结果数据订单信息上加上买入时刻的很多信息,'
                  u'比如价格位置、趋势走向、波动情况等等特征, 注意需要生成特征后回测速度效率会降低\n'
                  u'如在下拉选择中选中\'回测过程生成交易特征\'在回测完成后将保存回测结果,通过在\'裁判特征训练\'可进行查看并进行'
                  u'裁判训练',
            disabled=False,
            layout=widgets.Layout(height='150px')
        )

        self.enable_ml_feature = widgets.Dropdown(
            options={u'回测过程不生成交易特征': 0,
                     u'回测过程生成交易特征': 1},
            value=0,
            description=u'特征生成:',
        )
        return widgets.VBox([ml_feature_description, self.enable_ml_feature])