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


Python models.Button类代码示例

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


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

示例1: test_buttonclick_event_callbacks

def test_buttonclick_event_callbacks():
    button = Button()
    test_callback = EventCallback()
    button.on_event(events.ButtonClick, test_callback)
    assert test_callback.event_name == None
    button._trigger_event(events.ButtonClick(button))
    assert test_callback.event_name == events.ButtonClick.event_name
开发者ID:timsnyder,项目名称:bokeh,代码行数:7,代码来源:test_events.py

示例2: test_displays_button_type

    def test_displays_button_type(self, typ, bokeh_model_page):
        button = Button(button_type=typ, css_classes=["foo"])

        page = bokeh_model_page(button)

        button = page.driver.find_element_by_css_selector('.foo .bk-btn')
        assert typ in button.get_attribute('class')
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:7,代码来源:test_button.py

示例3: modify_doc

        def modify_doc(doc):
            plot = Plot(plot_height=400, plot_width=400, x_range=Range1d(0, 1), y_range=Range1d(0, 1), min_border=0)
            plot.add_tools(CustomAction(callback=CustomJS(args=dict(s=source), code=RECORD("data", "s.data"))))

            button = Button(css_classes=["foo"])
            button.js_on_click(CustomJS(args=dict(s=source), code="s.patch({'x': [[1, 100]]})"))
            doc.add_root(column(button, plot))
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:7,代码来源:test_sources.py

示例4: root

def root():
    scrape_button = Button(label='Scrape Data')
    prices = scrape_button.on_click(scrape_prices(url))
    #prices = scrape_prices(url)
    p = make_hist(prices)
    script, div = embed.components(p,scrape_button)
    return render_template('histograms.html',script = script,div = div)
开发者ID:dmastropole,项目名称:RentCompare,代码行数:7,代码来源:main.py

示例5: ButtonWrapper

class ButtonWrapper(object):
    def __init__(self, label, callback):
        self.ref = "button-" + make_id()
        self.obj = Button(label=label, css_classes=[self.ref])
        self.obj.js_on_event('button_click', callback)

    def click(self, driver):
        button = driver.find_element_by_css_selector(".%s .bk-btn" % self.ref)
        button.click()
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:9,代码来源:selenium.py

示例6: modify_doc

 def modify_doc(doc):
     source = ColumnDataSource(dict(x=[1, 2], y=[1, 1]))
     plot = Plot(plot_height=400, plot_width=400, x_range=Range1d(0, 1), y_range=Range1d(0, 1), min_border=0)
     plot.add_glyph(source, Circle(x='x', y='y', size=20))
     plot.add_tools(CustomAction(callback=CustomJS(args=dict(s=source), code=RECORD("data", "s.data"))))
     button = Button(css_classes=['foo'])
     def cb(event):
         source.data=dict(x=[10, 20], y=[10, 10])
     button.on_event('button_click', cb)
     doc.add_root(column(button, plot))
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:10,代码来源:test_button.py

示例7: root

def root():
    
    # add a button widget and configure with the call back
    button = Button(label="Press Me")
    button.on_click(scrape_prices(url))
    p = make_hist(prices)
    #layout = vform(button, p)
    #script, div = embed.components(layout)
    script, div = embed.components(p,button)
    
    return render_template('histograms.html',script = script,div = div)
开发者ID:dmastropole,项目名称:RentCompare,代码行数:11,代码来源:main.py

示例8: test_js_on_click_executes

    def test_js_on_click_executes(self, bokeh_model_page):
        button = Button(css_classes=['foo'])
        button.js_on_click(CustomJS(code=RECORD("clicked", "true")))

        page = bokeh_model_page(button)

        button = page.driver.find_element_by_css_selector('.foo .bk-btn')
        button.click()

        results = page.results
        assert results == {'clicked': True}

        assert page.has_no_console_errors()
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:13,代码来源:test_button.py

示例9: run

def run(doc):

    fig = figure(title='random data', width=400, height=200, tools='pan,box_zoom,reset,save')

    source = ColumnDataSource(data={'x': [], 'y': []})
    fig.line('x', 'y', source=source)

    def click(n=100):
        source.data = {'x': range(n), 'y': random(n)}

    button = Button(label='update', button_type='success')
    button.on_click(click)

    layout = column(widgetbox(button), fig)
    doc.add_root(layout)
    click()
开发者ID:russellburdt,项目名称:data-science,代码行数:16,代码来源:run_bokeh.py

示例10: modify_doc

        def modify_doc(doc):

            plot = Plot(plot_height=400, plot_width=400, x_range=Range1d(0, 1), y_range=Range1d(0, 1), min_border=0)
            plot.add_tools(CustomAction(callback=CustomJS(args=dict(s=source), code=RECORD("data", "s.data"))))

            table = DataTable(columns=[
                TableColumn(field="x", title="x", sortable=True),
                TableColumn(field="y", title="y", sortable=True)
            ], source=source, editable=False)

            button = Button(css_classes=["foo"])
            def cb():
                source.stream({'x': [100], 'y': [100]})
            button.on_click(cb)

            doc.add_root(column(plot, table, button))
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:16,代码来源:test_source_updates.py

示例11: create_goto_event_id_widget

 def create_goto_event_id_widget(self):
     self.w_goto_event_id = Button(
         label="GOTO ID",
         button_type="default",
         width=70
     )
     self.w_goto_event_id.on_click(self.on_goto_event_id_widget_click)
开发者ID:ParsonsRD,项目名称:ctapipe,代码行数:7,代码来源:file_viewer.py

示例12: create_goto_event_index_widget

 def create_goto_event_index_widget(self):
     self.w_goto_event_index = Button(
         label="GOTO Index",
         button_type="default",
         width=100
     )
     self.w_goto_event_index.on_click(self.on_goto_event_index_widget_click)
开发者ID:ParsonsRD,项目名称:ctapipe,代码行数:7,代码来源:file_viewer.py

示例13: create_previous_event_widget

 def create_previous_event_widget(self):
     self.w_previous_event = Button(
         label="<",
         button_type="default",
         width=50
     )
     self.w_previous_event.on_click(self.on_previous_event_widget_click)
开发者ID:ParsonsRD,项目名称:ctapipe,代码行数:7,代码来源:file_viewer.py

示例14: test_event_handles_new_callbacks_in_event_callback

    def test_event_handles_new_callbacks_in_event_callback(self):
        from bokeh.models import Button
        d = document.Document()
        button1 = Button(label="1")
        button2 = Button(label="2")
        def clicked_1():
            button2.on_click(clicked_2)
            d.add_root(button2)
        def clicked_2():
            pass

        button1.on_click(clicked_1)
        d.add_root(button1)

        event_json = json.dumps({"event_name":"button_click","event_values":{"model_id":button1.id}})
        try:
            d.apply_json_event(event_json)
        except RuntimeError:
            pytest.fail("apply_json_event probably did not copy models before modifying")
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:19,代码来源:test_document.py

示例15: plot

def plot():

    import numpy as np

    from bokeh.models import Button
    from bokeh.palettes import RdYlBu3
    from bokeh.plotting import figure, vplot

    # create a plots and style its properties
    p = figure(x_range=(0, 100), y_range=(0, 100), toolbar_location=None)
    p.border_fill_color = 'black'
    p.background_fill_color = 'black'
    p.outline_line_color = None
    p.grid.grid_line_color = None

    # add a text renderer to out plots (no data yet)
    r = p.text(x=[], y=[], text=[], text_color=[], text_font_size="20pt",
               text_baseline="middle", text_align="center")

    i = 0

    ds = r.data_source

    # create a callback that will add a number in a random location
    def callback():
        nonlocal i
        ds.data['x'].append(np.random.random()*70 + 15)
        ds.data['y'].append(np.random.random()*70 + 15)
        ds.data['text_color'].append(RdYlBu3[i%3])
        ds.data['text'].append(str(i))
        ds.trigger('data', ds.data, ds.data)
        i = i + 1

    # add a button widget and configure with the call back
    button = Button(label="Press Me")
    button.on_click(callback)

    plot_this = vplot(button, p)

    return plot_this
开发者ID:ssb109,项目名称:WHOI_OOI_Glider_Repo,代码行数:40,代码来源:plot_test.py


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