Is it 'fine' to instantiate a widget without parent parameter?

David bouncingcats at gmail.com
Sun Sep 8 08:13:36 EDT 2019


On Sun, 8 Sep 2019 at 21:05, <jfong at ms4.hinet.net> wrote:
> David於 2019年9月8日星期日 UTC+8下午6時44分55秒寫道:
> > On Sun, 8 Sep 2019 at 20:25, <jfong at ms4.hinet.net> wrote:

> > > If I have two widgets created this way:
> > > t0 = tkinter.Text()
> > > t1 = tkinter.Text()
> > > How many Tk objects will there be?

> Sorry, didn't make it clear. I mean <tkinter.Tk object .>

Sorry I didn't read more carefully.
But I think that the method I demonstrated can give
the answer to your question.

>>> import tkinter
>>> t0 = tkinter.Text()
>>> t1 = tkinter.Text()
>>> t0.master
<tkinter.Tk object .>
>>> t1.master
<tkinter.Tk object .>
>>> t0.master is t1.master
True
>>>



More information about the Python-list mailing list