Is it 'fine' to instantiate a widget without parent parameter?
jfong at ms4.hinet.net
jfong at ms4.hinet.net
Sun Sep 8 06:20:26 EDT 2019
Terry Reedy於 2019年9月8日星期日 UTC+8下午5時31分34秒寫道:
> On 9/7/2019 9:44 PM, jfong at ms4.hinet.net wrote:
> > I know it is valid, according to the Tkinter source, every widget constructor has a 'master=None' default. What happens on doing this?
>
> Tkinter creates a default Tk object and uses that as the master.
>
> >>> t = tkinter.Text()
> >>> t.master
> <tkinter.Tk object .>
>
> > In what circumstance, we do it this way? and will it cause any trouble?
>
> I believe it is OK if you always do it that way within a single
> application. But I prefer to have an explicit reference and use that
> for .after calls and some others.
>
>
> --
> Terry Jan Reedy
If I have two widgets created this way:
t0 = tkinter.Text()
t1 = tkinter.Text()
How many Tk objects will there be?
--Jach
More information about the Python-list
mailing list