本文整理汇总了Python中bokeh.models.Button.js_on_event方法的典型用法代码示例。如果您正苦于以下问题:Python Button.js_on_event方法的具体用法?Python Button.js_on_event怎么用?Python Button.js_on_event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bokeh.models.Button
的用法示例。
在下文中一共展示了Button.js_on_event方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ButtonWrapper
# 需要导入模块: from bokeh.models import Button [as 别名]
# 或者: from bokeh.models.Button import js_on_event [as 别名]
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()
示例2: test_js_on_event_executes
# 需要导入模块: from bokeh.models import Button [as 别名]
# 或者: from bokeh.models.Button import js_on_event [as 别名]
def test_js_on_event_executes(self, bokeh_model_page):
button = Button(css_classes=['foo'])
button.js_on_event('button_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()
示例3: Div
# 需要导入模块: from bokeh.models import Button [as 别名]
# 或者: from bokeh.models.Button import js_on_event [as 别名]
# Add a div to display events and a button to trigger button click events
div = Div(width=1000)
button = Button(label="Button", button_type="success")
layout = column(button, row(p, div))
point_attributes = ['x','y','sx','sy']
pan_attributes = point_attributes + ['delta_x', 'delta_y']
pinch_attributes = point_attributes + ['scale']
wheel_attributes = point_attributes+['delta']
## Register Javascript event callbacks
# Button event
button.js_on_event(events.ButtonClick, display_event(div))
# LOD events
p.js_on_event(events.LODStart, display_event(div))
p.js_on_event(events.LODEnd, display_event(div))
# Point events
p.js_on_event(events.Tap, display_event(div, attributes=point_attributes))
p.js_on_event(events.DoubleTap, display_event(div, attributes=point_attributes))
p.js_on_event(events.Press, display_event(div, attributes=point_attributes))
# Mouse wheel event
p.js_on_event(events.MouseWheel, display_event(div,attributes=wheel_attributes))
# Mouse move, enter and leave