當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。