def toggle_auto_update(new): global file_update_callback if new is False and file_update_callback in doc._session_callbacks: doc.remove_periodic_callback(file_update_callback) elif file_update_callback not in doc._session_callbacks: file_update_callback = doc.add_periodic_callback( reload_all_files, 30000)
toggle_auto_update(False) def resume_auto_update_according_to_toggle(): toggle_auto_update(auto_update_toggle_button.active) def toggle_auto_update(new): global file_update_callback if new is False and file_update_callback in doc._session_callbacks: doc.remove_periodic_callback(file_update_callback) elif file_update_callback not in doc._session_callbacks: file_update_callback = doc.add_periodic_callback(reload_all_files, 30000) file_update_callback = doc.add_periodic_callback(reload_all_files, 30000) # ---------------- Build Website Layout ------------------- # file refresh time placeholder refresh_info = Div(text="""""", width=210) # create figures plot = figure(plot_width=1200, plot_height=800, # tools='pan,box_zoom,wheel_zoom,crosshair,undo,redo,reset,save', toolbar_location=None, x_axis_label='Episodes', x_range=Range1d(0, 10000), y_range=Range1d(0, 100000), lod_factor=1000) plot.extra_y_ranges = {"secondary": Range1d(start=-100, end=200)} plot.add_layout(LinearAxis(y_range_name="secondary"), 'right') toolbar = Toolbar(tools=[PanTool(), BoxZoomTool(), WheelZoomTool(), CrosshairTool(), ResetTool(), SaveTool()]) # plot.toolbar = toolbar