![](/img/trans.png)
[英]How to find and click the button by "onclick" with Selenium and Python?
[英]How to perform an onclick action on button click in python bokeh?
我是bokeh的新手,我对按钮onclick事件有一个查询,下面提供了代码:
x = widgetbox(button)
show(x)
fruits = ['Answered', 'Unanswered','Total']
top1=[1,2,3]
def callback():
p = figure(x_range=fruits, plot_height=250, title="sophia bot")
p.vbar(x=fruits, top=top1, width=0.9)
p.xgrid.grid_line_color = None
p.y_range.start = 0
output_file("abc.html")
show(p)
button_one = Button(label="Start", disabled=True, callback=callback)
show(button_one)
但这不是执行操作,下面的代码单独使用时,确实会绘制图形,我希望在单击按钮时沿原样显示图形。
fruits = ['Answered', 'Unanswered','Total']
top1=[1,2,3]
p = figure(x_range=fruits, plot_height=250, title="sophia bot")
p.vbar(x=fruits, top=top1, width=0.9)
p.xgrid.grid_line_color = None
p.y_range.start = 0
output_file("abc.html")
show(p)
谢谢
您必须将回调分配给按钮,如下所示:
from bokeh.models import Button
from bokeh.io import curdoc
bt = Button(label='Click me')
def change_click():
print('I was clicked')
bt.on_click(change_click)
curdoc().add_root(bt)
使用bokeh serve --show example.py
启动它。
注 :也看看我的问题 ,我谈的动态布局
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.