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 = Dropdown(label="Dropdown button", menu=items, css_classes=["foo"]) def cb(event): item = event.item if item == "item_1_value": source.data = dict(x=[10, 20], y=[10, 10]) elif item == "item_2_value": source.data = dict(x=[100, 200], y=[100, 100]) elif item == "item_3_value": source.data = dict(x=[1000, 2000], y=[1000, 1000]) button.on_event('menu_item_click', cb) doc.add_root(column(button, plot))
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 = Dropdown(label="Dropdown button", menu=items, css_classes=["foo"]) def cb(event): item = event.item if item == "item_1_value": source.data = dict(x=[10, 20], y=[10, 10]) elif item == "item_2_value": source.data = dict(x=[100, 200], y=[100, 100]) elif item == "item_3_value": source.data = dict(x=[1000, 2000], y=[1000, 1000]) button.on_event('menu_item_click', cb) doc.add_root(column(button, plot))
start=CACHE.graph_attr.min_timestep, end=CACHE.graph_attr.timesteps, value=CACHE.plot.timestep, step=1, **STATIC.widget.slider) timestep_slider.on_change('value_throttled', VisualizerHandler.timestep_callback) CACHE.widgets.timestep_slider = timestep_slider # ------------------ Layouts widgets ------------------- # layout_title = h1("Layout settings") layout_algo_dropdown = Dropdown(label="Layout algorithm", menu=from_dict_to_menu(layouts.AVAILABLE)) layout_algo_dropdown.on_event('menu_item_click', VisualizerHandler.layout_algo_callback) CACHE.widgets.layout_algo_dropdown = layout_algo_dropdown # ------------------ Edges widgets ------------------- # edges_title = h1("Edges settings") thickness_slider = Slider(title="Edge thickness", start=.05, end=5, value=CACHE.plot.network.edges.thickness, step=.05, **STATIC.widget.slider) thickness_slider.on_change('value_throttled', VisualizerHandler.thickness_callback) CACHE.widgets.thickness_slider = thickness_slider
'V1', 'V2', 'Gamma1', 'Gamma2' ]) dataRecordingLabel.visible = not dataRecordingLabel.visible dataRecordingButton.on_click(recordingButtonClicked) # Dropdown def extensionsDropdownChanged(event): global extension extension = event.item extensionsDropdown.on_event(MenuItemClick, extensionsDropdownChanged) # Tabs def panelActive(attr, old, new): global automatico, primer_ciclo ''' Get excecuted when the other tab is selected Changes the operation mode if a tab is changed ''' if tabs.active == 0: automatico = True primer_ciclo = True elif tabs.active == 1: automatico = False voltageV1.value = cliente.valvulas['valvula1'].get_value()