热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

pythonbokehslider_Pythonwidgets.Slider方法代码示例

#需要导入模块:frombokeh.modelsimportwidgets[as别名]#或者:frombokeh.models.widgetsimportSlider[as别名]d

# 需要导入模块: from bokeh.models import widgets [as 别名]

# 或者: from bokeh.models.widgets import Slider [as 别名]

def update_effect(attrname, old, new):

global effect, model, knob_names, knob_ranges, num_knobs, knob_sliders

# match the menu option with the right entry in effects_dict

long_name = effect_select.value

plot.title.text = f"Trying to setup effect '{long_name}'..."

shortname = ''

for key, val in effects_dict.items():

if val['name'] == long_name:

shortname = key

break

if '' == shortname:

plot.title.text = f"**ERROR: Effect '{long_name}' not defined**"

return

effect = effects_dict[shortname]['effect']

num_knobs = 0

if effect is not None:

knob_names, knob_ranges = effect.knob_names, np.array(effect.knob_ranges)

num_knobs = len(knob_names)

# try to read the checkpoint file

checkpoint_file = effects_dict[shortname]['checkpoint']

model = setup_model(checkpoint_file, fatal=False)

if model is None:

msg = f"**ERROR: checkpoint file '{checkpoint_file}' not found**"

print("\n",msg)

plot.title.text = msg

# rebuild the entire display (because knobs have changed)

knob_sliders = []

if num_knobs > 0:

knobs_wc = knob_ranges.mean(axis=1)

for k in range(num_knobs):

start, end = knob_ranges[k][0], knob_ranges[k][1]

mid = knobs_wc[k]

step = (end-start)/25

tmp = Slider(title=knob_names[k], value=mid, start=start, end=end, step=step)

knob_sliders.append(tmp)

for w in knob_sliders: # since we now defined new widgets, we need triggers for them

w.on_change('value', update_data)

inputs = column([effect_select, input_select]+knob_sliders )

curdoc().clear()

curdoc().add_root(row(inputs, plot, width=800))

curdoc().title = "SignalTrain Demo"

update_data(attrname, old, new)



推荐阅读
author-avatar
郭雪峰Rongeqw_983
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有