A n
parameter may be given to tkinter.mainloop
function,
help(tkinter.Tk.mainloop)
>>>> mainloop(self, n=0) # What is n her
As you can see in the C implementation of Tkinter , _tkinter_tkapp_mainloop_impl,
_tkinter_tkapp_mainloop_impl(TkappObject *self, int threshold)
n
represent the threshold
parameter passed to the function.
Now, looking at the implementation itself, it is possible to see this loop at the beginning of the function,
while (Tk_GetNumMainWindows() > threshold &&
!quitMainLoop &&
!errorInCmd)
Hence, you can see that the code is meant to drop out of the mainloop
when the number of root level windows drops to threshold
or below.
Note that by default the optional parameter will have a value of 0
which logically means it will stay active if any root level windows are opened.
Further information
I can't comment on why this threshold
parameter was added, but the lack of documentation and/or information on this specific parameter most likely comes from the fact that it seems quite rare that someone would pass n
explicitly to tkinter.mainloop
and change the default behavior.