title: Force update of bokeh widgets?
body: <p>I am new to bokeh and writing a small bokeh server app, which has plot and a button. When the button is pressed, data is recalculated and plot updates. The idea is that as soon as the button pressed, it changes the color and label, also a text "calculating..." appears. When calculations are done, plot updates and the text disappears.</p>
  
  <p>However, when button is pressed, it doesn't change color and the text does not appear before the calculations are done (takes several seconds). All this widget update happens after calculations. Question, is it possible to force a widget to update, like flush=True in case of print() or something similar may be? </p>
  
  <p>I could not find anything in bokeh documetation. I have tried also to separate widget changes and calculations and execute them in two separate functions, but it didn't help. Setting a delay between button change and invoke of calculation function also did not help. Seems, like update on widgets only happens on exit from callback function or even later. The only thing which I did not check is CustomJS, but I don't know how to write js code for button update.</p>
  
  <p>Thanks for any help! </p>
  
  <p>Here is a code sample close to what I actually use:</p>
  
  <pre><code>from bokeh.plotting import figure
  from bokeh.models import Button, PreText, ColumnDataSource
  from bokeh.layouts import row
  
  p = figure()
  source = ColumnDataSource(data={"x":[0], "y":[0]})
  p.line(x="x", y="y", source=source)
  variable = False
  
  # initialise widgets
  switchButton = Button(label='Anticrossing OFF', button_type="default")
  process_markup = PreText(text='Calculating...', visible=False)
  
  def callback(arg):
      global variable
      global process_markup
  
      variable = not variable
  
      # change button style
      if variable:
          switchButton.update(label = 'Anticrossing ON',
                                button_type = 'success')
      else:
          switchButton.update(label = 'Anticrossing OFF',
                                button_type = 'default')
      # show "calculating..."
      process_markup.update(visible=True)
  
      # do long calculations
      x, y = calculate_data(variable)
      source.data = {"x":x, "y":y}
  
      # hide "calculating..."
      process_markup.update(visible=False)
  
  switchButton.on_click(callback)
  col = column(switchButton, process_markup)
  curdoc().add_root(row(col, p))
  </code></pre>