本文整理汇总了Python中bokeh.models.Button.on_event方法的典型用法代码示例。如果您正苦于以下问题:Python Button.on_event方法的具体用法?Python Button.on_event怎么用?Python Button.on_event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bokeh.models.Button
的用法示例。
在下文中一共展示了Button.on_event方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_buttonclick_event_callbacks
# 需要导入模块: from bokeh.models import Button [as 别名]
# 或者: from bokeh.models.Button import on_event [as 别名]
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
示例2: modify_doc
# 需要导入模块: from bokeh.models import Button [as 别名]
# 或者: from bokeh.models.Button import on_event [as 别名]
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))
示例3: display_event
# 需要导入模块: from bokeh.models import Button [as 别名]
# 或者: from bokeh.models.Button import on_event [as 别名]
# Pan events
p.js_on_event(events.Pan, display_event(div, attributes=pan_attributes))
p.js_on_event(events.PanStart, display_event(div, attributes=point_attributes))
p.js_on_event(events.PanEnd, display_event(div, attributes=point_attributes))
# Pinch events
p.js_on_event(events.Pinch, display_event(div, attributes=pinch_attributes))
p.js_on_event(events.PinchStart, display_event(div, attributes=point_attributes))
p.js_on_event(events.PinchEnd, display_event(div, attributes=point_attributes))
## Register Python event callbacks
# Button event
button.on_event(events.ButtonClick, print_event())
# LOD events
p.on_event(events.LODStart, print_event())
p.on_event(events.LODEnd, print_event())
# Point events
p.on_event(events.Tap, print_event(attributes=point_attributes))
p.on_event(events.DoubleTap, print_event(attributes=point_attributes))
p.on_event(events.Press, print_event(attributes=point_attributes))
# Mouse wheel event
p.on_event(events.MouseWheel, print_event(attributes=wheel_attributes))
# Mouse move, enter and leave
示例4: ColumnDataSource
# 需要导入模块: from bokeh.models import Button [as 别名]
# 或者: from bokeh.models.Button import on_event [as 别名]
x = np.linspace(0, 2, 1000)
y = 1 - (x-1)**2
source = ColumnDataSource(data=dict(x=x, y=y))
p = figure(title="initial title")
p.circle(x=1, y=list(range(0, 11)))
p.line('x', 'y', color="orange", source=source)
slider = Slider(start=0, end=10, step=0.1, value=1)
def scb(attr, old, new):
source.data['y'] = new * y
slider.on_change('value', scb)
combine = Button(label="hold combine")
combine.on_event(ButtonClick, lambda event: doc.hold("combine"))
collect = Button(label="hold collect")
collect.on_event(ButtonClick, lambda event: doc.hold("collect"))
unhold = Button(label="unhold")
unhold.on_event(ButtonClick, lambda event: doc.unhold())
doc.add_root(column(p, slider, combine, collect, unhold))
@repeat(np.linspace(0, 10, 100))
def update(v):
slider.value = v
curdoc().add_periodic_callback(update, 200)