[Tkinter-discuss] the difference between mainloop and app.mainloop and root.mainloop?

Michael Lange klappnase at web.de
Wed Aug 24 20:04:49 CEST 2011


Thus spoketh Steve Oldner <Steven.Oldner at LA.GOV> 
unto us on Wed, 24 Aug 2011 06:47:51 -0500:

> So all three can be used, but which would be the more 'pythonic' way?

How would I dare to decide this ;) ?

If we look at the relevant parts of the IDLE code we find the following,
and if they do it this way I guess that at least it can't be bad ;)


    def main():
        (...lots of code...)
        # start editor and/or shell windows:
        root = Tk(className="Idle")

        fixwordbreaks(root)
        root.withdraw()
        (...some more lots of code...)

        root.mainloop()
        root.destroy()

    if __name__ == "__main__":
        sys.modules['PyShell'] = sys.modules['__main__']
        main()

Regards

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

Suffocating together ... would create heroic camaraderie.
		-- Khan Noonian Singh, "Space Seed", stardate 3142.8


More information about the Tkinter-discuss mailing list