def test_callback_property_executes(self, single_plot_page): 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)) text_input = TextInput(css_classes=['foo']) text_input.callback = CustomJS(code=RECORD("value", "cb_obj.value")) page = single_plot_page(column(text_input, plot)) el = page.driver.find_element_by_css_selector('.foo input') enter_text_in_element(page.driver, el, "val1") results = page.results assert results['value'] == 'val1' # double click to highlight and overwrite old text enter_text_in_element(page.driver, el, "val2", click=2) results = page.results assert results['value'] == 'val2' # Check clicking outside input also triggers enter_text_in_element(page.driver, el, "val3", click=2, enter=False) page.click_canvas_at_position(10, 10) results = page.results assert results['value'] == 'val3' assert page.has_no_console_errors()
def test_callback_property_executes(self, single_plot_page): 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)) text_input = TextInput(css_classes=['foo']) text_input.callback = CustomJS(code=RECORD("value", "cb_obj.value")) page = single_plot_page(column(text_input, plot)) el = page.driver.find_element_by_class_name('foo') enter_text_in_element(page.driver, el, "val1") results = page.results assert results['value'] == 'val1' # double click to highlight and overwrite old text enter_text_in_element(page.driver, el, "val2", click=2) results = page.results assert results['value'] == 'val2' # Check clicking outside input also triggers enter_text_in_element(page.driver, el, "val3", click=2, enter=False) page.click_canvas_at_position(10, 10) results = page.results assert results['value'] == 'val3' assert page.has_no_console_errors()
text_props['text_font_size'] = "8pt" plot.text(x=0.825, y=0.15, text="TP", source=conf_source, **text_props) plot.text(x=0.925, y=0.15, text="FP", source=conf_source, **text_props) plot.text(x=0.825, y=0.05, text="FN", source=conf_source, **text_props) plot.text(x=0.925, y=0.05, text="TN", source=conf_source, **text_props) update_data() text.on_change('value', input_change) dataurl.on_change('value', dataurl_change) # There must be a better way: dataurl.callback = CustomJS(args=dict(auc=auc, sample_size=sample_size), code=""" // $("label[for='"+auc.id+"']").parentNode.remove(); document.getElementById(auc.id).parentNode.hidden = true; // $("label[for='"+sample_size.id+"']").parentNode.remove(); document.getElementById(sample_size.id).parentNode.hidden = true; """) for w in (threshold, text, auc, sample_size): w.on_change('value', input_change) vbox_items = [text, sample_size, threshold, auc] if HAS_REQUESTS: vbox_items.append(dataurl) inputs = VBoxForm(*vbox_items) curdoc().add_root(HBox(inputs, plot, width=800))