title: How to get width of matplotlib figure window before entering the event loop?
body: <p>I am trying to determine the size of the current matplotlib figure window, such that I can reposition it correctly on the screen. This must be done before entering the event loop ( i.e. before calling <code>plt.show()</code> ). Here is an example:</p>
  
  <pre><code>import matplotlib
  import matplotlib.pyplot as plt
  
  def print_info(window):
      print("screen width: {}".format(window.winfo_screenwidth()))
      print("window width: {}".format(window.winfo_width()))
      return
  
  matplotlib.use('TkAgg')
  fig, axes = plt.subplots()
  axes.plot([1, 2, 3], [1, 4, 9], 'ro', label='Test')
  axes.set_title('Test curve')
  # plt.draw()  # &lt;-- this has no effect
  # fig.canvas.draw_idle()  # &lt;-- this has no effect
  window = plt.get_current_fig_manager().window
  # window.update() # &lt;-- this has no effect
  fig.canvas.mpl_connect('key_press_event', lambda event: print_info(window))
  #plt.pause(0.000001) # only entering the tk/pyplot event loop forces update
  print_info(window)
  plt.show()
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>screen width: 1920
  window width: 1
  </code></pre>
  
  <p>If I uncomment the <code>plt.pause(...)</code> call, it works fine (but I get a warning):</p>
  
  <pre><code>/home/hakon/.pyenv/versions/3.6.1/lib/python3.6/site-packages/matplotlib/backend_bases.py:2453: MatplotlibDeprecationWarning: Using default event loop until function specific to this GUI is implemented
    warnings.warn(str, mplDeprecation)
  screen width: 1920
  window width: 640
  </code></pre>
  
  <h2>Questions:</h2>
  
  <ul>
  <li>How can I avoid calling <code>plt.pause()</code> to get the correct window width?</li>
  <li>If the only option I have is to call <code>plt.pause()</code>, what is then the reason for the warning?</li>
  </ul>