def make_dropdown(prop, menu):
    dropdown = Dropdown(label=prop, menu=menu)
    cb = CustomJS(args=dict(lines=lines, prop=prop), code="""
        for (var i = 0; i < lines.length; i++) {
            const glyph = lines[i].glyph;
            glyph[prop] = cb_obj.item;
        }
    """)
    dropdown.js_on_click(cb)
    return dropdown
    def auxiliary_apps_dropdown(self):
        """Return a button that opens statistics application.
        """
        js_code = """
        switch (this.item) {
            case "Statistics":
                window.open('/statistics');
                break;
            case "Hitrate":
                window.open('/hitrate');
                break;
            case "ROI Intensities":
                window.open('/roi_intensities');
                break;
            case "ROI Pump-Probe":
                window.open('/roi_pump_probe');
                break;
            case "ROI Projections":
                window.open('/roi_projections');
                break;
            case "Radial Profile":
                window.open('/radial_profile');
                break;
        }
        """
        auxiliary_apps_dropdown = Dropdown(
            label="Open Auxiliary App",
            menu=[
                "Statistics",
                "Hitrate",
                "ROI Intensities",
                "ROI Pump-Probe",
                "ROI Projections",
                "Radial Profile",
            ],
            default_size=145,
        )
        auxiliary_apps_dropdown.js_on_click(CustomJS(code=js_code))

        return auxiliary_apps_dropdown
예제 #3
0
파일: buttons.py 프로젝트: zmj2008/bokeh
    ))

toggle_active = Toggle(label="Toggle button (initially active)",
                       button_type="success",
                       active=True)
toggle_active.js_on_click(
    CustomJS(
        code=
        "console.log('toggle(active): active=' + this.active, this.toString())"
    ))

menu = [("Item 1", "item_1_value"), ("Item 2", "item_2_value"), None,
        ("Item 3", "item_3_value")]

dropdown = Dropdown(label="Dropdown button", button_type="warning", menu=menu)
dropdown.js_on_click(
    CustomJS(code="console.log('dropdown: click ' + this.toString())"))
dropdown.js_on_event(
    "menu_item_click",
    CustomJS(code="console.log('dropdown: ' + this.item, this.toString())"))

dropdown_disabled = Dropdown(label="Dropdown button (disabled)",
                             button_type="warning",
                             disabled=True,
                             menu=menu)
dropdown_disabled.js_on_click(
    CustomJS(
        code="console.log('dropdown(disabled): click ' + this.toString())"))
dropdown_disabled.js_on_event(
    "menu_item_click",
    CustomJS(
        code="console.log('dropdown(disabled): ' + this.item, this.toString())"