title: get bounding box of a text and update the canvas
body: <p>Similarly as in this question <a href="https://stackoverflow.com/questions/30890831/change-text-style-inline-in-matplotlib">change text style inline in matplotlib</a> I want to write two labels in different styles (bold and normal, e.g. "<strong>bold</strong> normal") as if they were the same label without using latex.</p>
  
  <p>Here something that it is working:</p>
  
  <pre><code>from matplotlib import pyplot as plt
  
  fig, ax = plt.subplots()
  
  def print_label(fig):
      l = fig.text(0.5, 0.5, "bold", fontweight='bold')
      def on_draw(event):
          xmax = l.get_window_extent().inverse_transformed(fig.transFigure).max[0]
          print xmax
          fig.text(xmax, 0.5, "Normal")
          return False
      fig.canvas.mpl_connect('draw_event', on_draw)
  
  print_label(fig)
  fig.canvas.draw()
  plt.show()
  </code></pre>
  
  <p>but I am not happy since the usage of <code>print_label</code> is not transparent: the user has to call <code>fig.canvas.draw()</code>. So I tried this:</p>
  
  <pre><code>from matplotlib import pyplot as plt
  
  fig, ax = plt.subplots()
  
  def print_label(fig):
      l = fig.text(0.5, 0.5, "bold", fontweight='bold')
      def on_draw(event):
          xmax = l.get_window_extent().inverse_transformed(fig.transFigure).max[0]
          print xmax
          fig.text(xmax, 0.5, "Normal")
          fig.canvas.mpl_disconnect(event)
          fig.canvas.draw()
          return False
      fig.canvas.mpl_connect('draw_event', on_draw)
  
  print_label(fig)
  plt.show()
  </code></pre>
  
  <p>the problem there is that I am not able to disconnect the event, and I am getting:</p>
  
  <pre><code>RuntimeError: maximum recursion depth exceeded while calling a Python object
  </code></pre>