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

Steve Oldner Steven.Oldner at LA.GOV
Wed Aug 24 20:26:27 CEST 2011


Thanks.  I have seen this in some code snippets, but not have seen the destroy()

def main():
    root = Tk() 
    #stuff here
    root.mainloop()


if __name__ == '__main__':
    main()



-----Original Message-----
From: tkinter-discuss-bounces+steven.oldner=la.gov at python.org [mailto:tkinter-discuss-bounces+steven.oldner=la.gov at python.org] On Behalf Of Michael Lange
Sent: Wednesday, August 24, 2011 1:05 PM
To: tkinter-discuss at python.org
Subject: Re: [Tkinter-discuss] the difference between mainloop and app.mainloop and root.mainloop?

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
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss at python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


More information about the Tkinter-discuss mailing list