[Tkinter-discuss] root

Pierre Dagenais pierre.dagenais at ncf.ca
Tue Feb 4 22:29:48 CET 2014



On 14-02-04 04:07 PM, Bryan Oakley wrote:
> You must have a root window. If you do not create one, one will be created
> for you. That's just how tkinter works.
> 
> PEP-20 says "Explicit is better than implicit", so explicitly creating the
> root window is better than letting tkinter implicitly create it for you.
> 
Makes a lot of sense!
Thank you,
> 
> On Tue, Feb 4, 2014 at 2:08 PM, Pierre Dagenais <pierre.dagenais at ncf.ca>wrote:
> 
>> This program, example1.py:
>>
>>> from tkinter import *
>>>
>>> root = Tk()
>>> canvas = Canvas()
>>> canvas.pack()
>>>
>>> root.mainloop()
>>
>>
>> and this one, example2.py:
>>
>>> from tkinter import *
>>>
>>> canvas = Canvas()
>>> canvas.pack()
>>>
>>> mainloop()
>>
>> do exactly the same thing, as far as I can tell. Yet, most examples I
>> find on the net use the first form. Why?
>> I must be missing something, but I can't figure what is the utility of
>> root. Can you help?
>>
>> PierreD.
>> _______________________________________________
>> Tkinter-discuss mailing list
>> Tkinter-discuss at python.org
>> https://mail.python.org/mailman/listinfo/tkinter-discuss
>>
> 


More information about the Tkinter-discuss mailing list