title: Python Tkinter Flashing Standard Window
body: <p>I am building an Interface with TKinter and I have the problem, that whenever create a new window the standardized tkinter window of 200x200 pixel with nothing in it flashes up for a fraction of a second and AFTER that all my modifications (widgets ect.) are made. This happens before AND after calling the mainloop. </p>
  
  <ul>
  <li>The Main-Interface is created.</li>
  <li>Mainloop stats  </li>
  <li>Flashing window  </li>
  <li>Main-Interface appears  </li>
  </ul>
  
  <p>Also after Mainloop was called this happens with newly created windows.</p>
  
  <ul>
  <li>Main-Interface appears--> Push a button, that creates a new window</li>
  <li>Flashing window</li>
  <li>new window appears</li>
  </ul>
  
  <p>Sadly I cannot give you a sample code... If I try to do a minimal example, this doesn't happen. Maybe the standard window is created, but it is changed so fast, that it doesn't appear on screen. I don't even know what to look up in this case... searching "tkinter flashing window" yields nothing.    </p>
  
  <p><strong>EDIT:</strong> I found the source of the problem. It seems to be caused by <code>wm_iconbitmap</code>, <code>FigureCanvasTkAgg</code> and <code>tkinter.Toplevel</code>. If you remove the the icon out of the code, it works fine, no flashing. But if I use it together with one of the other, the window flashes when created. Try it out with the code below. You have to put the icon in the working directory of course.</p>
  
  <p>Here is a code sample and <a href="https://www.dropbox.com/s/edmh1tkvku6g46z/icon.ico" rel="nofollow">the link</a> to the icon I am using, but I suppose any icon will do.</p>
  
  <pre><code># coding=utf-8
  import numpy as np
  import matplotlib as mpl
  from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
  import tkinter as tk
  import os
  
  class INTERFACE(object):
      def __init__(self):
          self.root = tk.Tk()
          self.root.protocol("WM_DELETE_WINDOW", self.EXIT)
          self.root.wm_iconbitmap( os.path.abspath("icon.ico"))  #&lt;---- !!!!!!
          self.root.geometry("1024x768")
          canvas = FigureCanvasTkAgg(self.testfigure(), master=self.root) #&lt;---- !!!!!!
          canvas.get_tk_widget().grid(sticky=tk.N+tk.W+tk.E+tk.S)
          self.root.rowconfigure(0, weight=1)
          self.root.columnconfigure(0, weight=1)
      def testfigure(self):
          x=np.linspace(0, 2*np.pi,100)
          y=np.sin(x)
          fig = mpl.figure.Figure()
          sub = fig.add_subplot(111)
          sub.plot(x,y)
          return fig
  
      def EXIT(self):
          Top = tk.Toplevel(master=self.root)
          Top.wm_iconbitmap( os.path.abspath("icon.ico"))  #&lt;---- !!!!!!
          Top.transient(self.root)
          Top.resizable(width=False, height=False)
          Top.title("Exit")
  
          tk.Message(Top,text="Do you really want to quit?", justify=tk.CENTER, width=300).grid(row=0,columnspan=3)
          tk.Button(Top,text="YES",command=self.root.destroy).grid(row=1,column=0)
          tk.Button(Top,text="No",command=self.root.destroy).grid(row=1,column=1)
          tk.Button(Top,text="Maybe",command=self.root.destroy).grid(row=1,column=2)
      def start(self):
          self.root.mainloop()
  
  if __name__ == '__main__':
      INTERFACE().start()
  </code></pre>