Using a bokeh serve as the backend for my script with buttons incorporated as follows
smoothing_button = Button(label = "smth selct elem") smoothing_button.on_click(lambda identity = self.attribute_ids[i], radio = radio_group, x_box = text_input_xval_integral, y_box = text_input_yval_integral: self.smoothing(identity, radio, x_box, y_box) )
(the lambda function is to capture context because I’m generating quite a lot of plots.)
the callback itself is fairly simple, it just computes an exponential moving average on the selected curve:
element = radio.labels[radio.active] lower_xdelim = float(x_box.value) lower_ydelim = float(y_box.value) source_local = getattr(self, attrname+"_"+element+"_source") #attr_id+"_"+dataset["sample element"]+"_source" x = np.array(source_local.data["x"]) y = np.array(source_local.data["y"]) alpha = 0.5 #some number between 0 and 1, needs be adjusted s1 = y ema = np.zeros(len(y)) ema = s1 j = 1 for val in y[1:]: ema[j] = alpha * val + (1-alpha) * ema[j-1] j += 1 source_local.data = dict(x = x, y = ema, element = [element for i in range(len(x))])
Which works as intended, with the caveat that when I press the button I get redirected to http://localhost:5006/?, pressing backspace takes me to the bokeh session I was working on with the updated plot. Inspecting the button object it seems alright (to me atleast):
smth selct elem
Any idea what’s going on here?