当前位置: 首页>>代码示例>>Python>>正文


Python ipywidgets.Button方法代码示例

本文整理汇总了Python中ipywidgets.Button方法的典型用法代码示例。如果您正苦于以下问题:Python ipywidgets.Button方法的具体用法?Python ipywidgets.Button怎么用?Python ipywidgets.Button使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ipywidgets的用法示例。


在下文中一共展示了ipywidgets.Button方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: show_mesh

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Button [as 别名]
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 
开发者ID:grossjohannes,项目名称:AlignNet-3D,代码行数:27,代码来源:pointcloud.py

示例2: add_text

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Button [as 别名]
def add_text(self, text, shading={}):
        self.update_shading(shading)
        tt = p3s.TextTexture(string=text, color=self.s["text_color"])
        sm = p3s.SpriteMaterial(map=tt)
        self.text = p3s.Sprite(material=sm, scaleToTexture=True)
        self.scene.add(self.text)

    #def add_widget(self, widget, callback):
    #    self.widgets.append(widget)
    #    widget.observe(callback, names='value')

#    def add_dropdown(self, options, default, desc, cb):
#        widget = widgets.Dropdown(options=options, value=default, description=desc)
#        self.__widgets.append(widget)
#        widget.observe(cb, names="value")
#        display(widget)

#    def add_button(self, text, cb):
#        button = widgets.Button(description=text)
#        self.__widgets.append(button)
#        button.on_click(cb)
#        display(button) 
开发者ID:skoch9,项目名称:meshplot,代码行数:24,代码来源:Viewer.py

示例3: __init__

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Button [as 别名]
def __init__(self, parent, props):
        super().__init__(layout=ipywidgets.Layout(align_items='flex-end'))
        self.parent = parent
        self.props = props
        self.install_button = ipywidgets.Button()
        self.install_button.add_class('nbv-table-row')
        self.remove_button = ipywidgets.Button(description='remove')
        self.remove_button.add_class('nbv-table-row')
        self.html = ipywidgets.HTML()

        if self.props['writable'] == 'INSTALLED':
            self.chidlren = (self.html,)
        else:
            self.children = (self.html, self.install_button, self.remove_button)
        self.install_button.on_click(self.install)
        self.remove_button.on_click(self.uninstall)
        self.rerender() 
开发者ID:Autodesk,项目名称:notebook-molecular-visualization,代码行数:19,代码来源:visualization.py

示例4: __init__

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Button [as 别名]
def __init__(self, mol):
        super().__init__(mol)

        self._atomset = collections.OrderedDict()

        self.atom_listname = ipy.Label('Selected atoms:', layout=ipy.Layout(width='100%'))
        self.atom_list = ipy.SelectMultiple(options=list(self.viewer.selected_atom_indices),
                                            layout=ipy.Layout(height='150px'))
        traitlets.directional_link(
            (self.viewer, 'selected_atom_indices'),
            (self.atom_list, 'options'),
            self._atom_indices_to_atoms
        )

        self.select_all_atoms_button = ipy.Button(description='Select all atoms')
        self.select_all_atoms_button.on_click(self.select_all_atoms)

        self.select_none = ipy.Button(description='Clear all selections')
        self.select_none.on_click(self.clear_selections)

        self.representation_buttons = ipy.ToggleButtons(options=['stick','ribbon', 'auto', 'vdw'],
                                                        value='auto')
        self.representation_buttons.observe(self._change_representation, 'value') 
开发者ID:Autodesk,项目名称:notebook-molecular-visualization,代码行数:25,代码来源:selection.py

示例5: _meta_wgt

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Button [as 别名]
def _meta_wgt(self):
        wgt_meta = {d: pnwgt.Select(
            name=d, options=v, height=45, width=120)
                    for d, v in self.meta_dicts.items()}
        def make_update_func(meta_name):
            def _update(x):
                self.metas[meta_name] = x.new
                self.update_subs()
            return _update
        for d, wgt in wgt_meta.items():
            cur_update = make_update_func(d)
            wgt.param.watch(cur_update, 'value')
        wgt_update = pnwgt.Button(
            name='Refresh', button_type='primary', height=30, width=120)
        wgt_update.param.watch(self.update_all, 'clicks')
        wgt_load = pnwgt.Button(
            name='Load Data', button_type='danger', height=30, width=120)
        wgt_load.param.watch(self.compute_subs, 'clicks')
        return pn.layout.WidgetBox(
            *(list(wgt_meta.values()) + [wgt_update, wgt_load]),
            width=150) 
开发者ID:DeniseCaiLab,项目名称:minian,代码行数:23,代码来源:visualization.py

示例6: __init__

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Button [as 别名]
def __init__(self, wg_manager):
        super(WidgetPickStockBase, self).__init__(wg_manager)
        self.add = widgets.Button(description=u'添加为全局选股策略', layout=widgets.Layout(width='98%'),
                                  button_style='info')
        # 添加全局选股策略指令按钮
        self.add.on_click(self.add_pick_stock)
        # 运行混入的BFSubscriberMixin中ui初始化
        self.subscriber_ui([u'点击\'已添加的买入策略\'框中的买入策略', u'将选股策略做为买入策略的附属选股策略'])
        # 买入策略框点击行为:将本卖出策略加到对应的买入策略做为附属
        self.buy_factors.observe(self.add_pick_stock_to_buy_factor, names='value')
        self.accordion.set_title(0, u'添加为指定买入因子的选股策略')
        accordion_shut(self.accordion)
        self.add_box = widgets.VBox([self.add, self.accordion])
        # 构建选股策略独有基础通用ui
        self._pick_stock_base_ui()
        # 具体子策略构建
        self._init_widget() 
开发者ID:bbfamily,项目名称:abu,代码行数:19,代码来源:ABuWGPSBase.py

示例7: __init__

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Button [as 别名]
def __init__(self, wg_manager):
        super(WidgetFactorBuyBase, 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_buy_factor)

            add_dp = widgets.Button(description=u'添加为寻找独立买入策略最佳组合', layout=widgets.Layout(width='98%'),
                                    button_style='warning')
            add_dp.on_click(self.add_buy_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_buy_factor)
        self._init_widget() 
开发者ID:bbfamily,项目名称:abu,代码行数:19,代码来源:ABuWGBFBase.py

示例8: show

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Button [as 别名]
def show(plot, get_data, fig=None):
    if fig is None:
        fig = figure()

    qbt = widgets.Button(description='Quit')
    qbt.value = False

    def cb(bt):
        qbt.value = True
        qbt.disabled = True

    qbt.on_click(cb)

    async def run():
        task = None
        for data in get_data():
            task = draw(fig, plot, data, task)
            if qbt.value == True:
                break
            await asyncio.sleep(0.05)

    fig.display()
    display(qbt)
    asyncio.ensure_future(run()) 
开发者ID:feihoo87,项目名称:QuLab,代码行数:26,代码来源:plot.py

示例9: __init__

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Button [as 别名]
def __init__(self,visuals,connection,**kwargs):
        ViewerBase.__init__(self,visuals,connection,**kwargs)

        width = self.getOpt("width","98%")
        height = self.getOpt("height","200px")

        self._max = self.getOpt("max",50);

        self._bg = self.getOpt("bg","#f8f8f8")
        self._border = self.getOpt("border","1px solid #d8d8d8")

        components = []
        self._log = widgets.HTML(value="",layout=widgets.Layout(width=width,height=height,border=self._border,overflow="auto"))
        components.append(self._log)

        self._filter = self.getOpt("filter")
        self._regex = None

        if self._filter != None:
            self._filterText = widgets.Text(description="Filter",value=self._filter,layout=widgets.Layout(width="70%"))
            if len(self._filter) > 0:
                self._regex = re.compile(self._filter,re.I)
            setButton = widgets.Button(description="Set")
            clearButton = widgets.Button(description="Clear")
            setButton.on_click(self.filter)
            clearButton.on_click(self.clearFilter)
            components.append(widgets.HBox([self._filterText,setButton,clearButton]))

        self._box = widgets.VBox(components,layout=widgets.Layout(width="100%"))

        s = ""
        s += "<div style='width:100%;height:100%;background:" + self._bg + "'>"
        s += "</div>"
        self._log.value = s

        self._messages = []

        self._connection.getLog().addDelegate(self)
        
        self.children = [self._box] 
开发者ID:sassoftware,项目名称:python-esppy,代码行数:42,代码来源:viewers.py

示例10: _create_widget

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Button [as 别名]
def _create_widget(self):
        btn = Button(description=self.desc, disabled=self.disabled, layout=self.layout)
        if self.on_click_hook:
            btn.on_click(lambda b: self.call_on_click_hook(b))
        return btn 
开发者ID:ideonate,项目名称:jupyter-innotater,代码行数:7,代码来源:uiinnotations.py

示例11: _create_widget

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Button [as 别名]
def _create_widget(self):
        self.addbtn = Button(description='Add')
        self.addbtn.on_click(self.add_row_handler)
        vbox = VBox([self.addbtn])
        vbox.add_class('repeat-innotation')
        return vbox 
开发者ID:ideonate,项目名称:jupyter-innotater,代码行数:8,代码来源:combine.py

示例12: ActionButton

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Button [as 别名]
def ActionButton(*args, **kw):
    """Returns a ipywidgets.Button executing a paramnb.Action."""
    kw['description'] = str(kw['name'])
    value = kw["value"]
    w = ipywidgets.Button(*args,**kw)
    if value: w.on_click(value)
    return w 
开发者ID:ioam,项目名称:paramnb,代码行数:9,代码来源:widgets.py

示例13: get_state

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Button [as 别名]
def get_state(self, key=None, drop_defaults=False):
        # HACK: Lets this composite widget pretend to be a regular widget
        # when included into a layout.
        if key in ['value', '_options_labels']:
            return super(CrossSelect, self).get_state(key)
        return self._composite.get_state(key)


# Composite widget containing a Dropdown and a Button in an HBox.
# Some things are routed to/from the Dropdown, others to/from the
# composite HBox. 
开发者ID:ioam,项目名称:paramnb,代码行数:13,代码来源:widgets.py

示例14: __init__

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Button [as 别名]
def __init__(self, *args, **kwargs):
        self._select = Dropdown(*args,**kwargs)
        self._edit = Button(description='...',
                            layout=Layout(width='15px'))
        self._composite = HBox([self._select,self._edit])
        super(DropdownWithEdit, self).__init__()
        self.layout = self._composite.layout
        # so that others looking at this widget's value get the
        # dropdown's value
        traitlets.link((self._select,'value'),(self,'value'))
        self._edit.on_click(lambda _: editor(self._select.value))
        self._select.observe(lambda e: self._set_editable(e['new']),'value')
        self._set_editable(self._select.value) 
开发者ID:ioam,项目名称:paramnb,代码行数:15,代码来源:widgets.py

示例15: resistances_image

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Button [as 别名]
def resistances_image(self):
        '''Widgets for resistance model selection'''

        self.w_res = widgets.ToggleButtons(
            description='Select TSEB model to run:',
            options={
                'Kustas & Norman 1999': 0,
                'Choudhury & Monteith 1988': 1,
                'McNaughton & Van der Hurk': 2},
            value=self.res,
            width=300)

        self.w_PT_But = widgets.Button(
            description='Browse Initial alphaPT Image')
        self.w_PT = widgets.Text(description=' ', value=str(self.max_PT), width=500)

        self.w_KN_b_But = widgets.Button(description='Browse Resistance Parameter b Image')
        self.w_KN_b = widgets.Text(
            value=str(self.KN_b), description=' ', width=500)
        self.w_KN_c_But = widgets.Button(description=('Browse Resistance Parameter c image'))
        self.w_KN_c = widgets.Text(
            value=str(self.KN_c), description='(m s-1 K-1/3)', width=500)
        self.w_KN_C_dash_But = widgets.Button(description=("Browse Resistance Parameter C' Image"))
        self.w_KN_C_dash = widgets.Text(
            value=str(self.KN_C_dash), description="s1/2 m-1", width=500)
        self.KN_params_box = widgets.VBox([widgets.HTML('Select resistance parameter b image or type a constant value'),
                                           widgets.HBox([self.w_KN_b_But, self.w_KN_b]),
                                           widgets.HTML('Select resistance parameter c image or type a constant value'),
                                           widgets.HBox([self.w_KN_c_But, self.w_KN_c]),
                                           widgets.HTML('Select resistance parameter C\' image or type a constant value'),
                                           widgets.HBox([self.w_KN_C_dash_But, self.w_KN_C_dash])], background_color='#EEE')
        self.res_page = widgets.VBox([self.w_res, self.KN_params_box], background_color='#EEE')

        self.w_KN_b_But.on_click(
            lambda b: self._on_input_clicked(b, 'Resistance Parameter b', self.w_KN_b))
        self.w_KN_c_But.on_click(
            lambda b: self._on_input_clicked(b, 'Resistance Parameter c', self.w_KN_c))
        self.w_KN_C_dash_But.on_click(
            lambda b: self._on_input_clicked(b, 'Resistance Parameter C\'', self.w_KN_C_dash)) 
开发者ID:hectornieto,项目名称:pyTSEB,代码行数:41,代码来源:TSEBIPythonInterface.py


注:本文中的ipywidgets.Button方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。