root.iconbitmap() forces tkinter to enter a temporary eventloop?
Question:
Does wm_iconbitmap
method forces tkinter to enter an event loop while it processes the icon file? Is there a way to avoid this? Check this example that illustrates this:
from tkinter import *
import time
root = Tk()
root.iconbitmap('images/logo.ico') # Without `mainloop()` shows the window, means the events have started being processed?
time.sleep(3)
I couldn’t find any related info in the documentation either.
Thanks in advance 🙂
Edit: A little more research shows that root.iconbitmap()
does not enter event loop, maybe because there is no icon to process/check? But that would not answer why root.iconphoto
does not enter an event-loop when called
Answers:
The eventloop and the created window are different things. In your case it is the window that is forced into existence and is mentioned in the source code as a side effect:
Side effects:
One or all windows may have their icon changed.
The Tcl result may be modified. The window-manager will be
initialised if it wasn’t already. The given window will be forced
into existence.
See the source code for details.
Does wm_iconbitmap
method forces tkinter to enter an event loop while it processes the icon file? Is there a way to avoid this? Check this example that illustrates this:
from tkinter import *
import time
root = Tk()
root.iconbitmap('images/logo.ico') # Without `mainloop()` shows the window, means the events have started being processed?
time.sleep(3)
I couldn’t find any related info in the documentation either.
Thanks in advance 🙂
Edit: A little more research shows that root.iconbitmap()
does not enter event loop, maybe because there is no icon to process/check? But that would not answer why root.iconphoto
does not enter an event-loop when called
The eventloop and the created window are different things. In your case it is the window that is forced into existence and is mentioned in the source code as a side effect:
Side effects:
One or all windows may have their icon changed.
The Tcl result may be modified. The window-manager will be
initialised if it wasn’t already. The given window will be forced
into existence.
See the source code for details.