Is it 'fine' to instantiate a widget without parent parameter?
Terry Reedy
tjreedy at udel.edu
Sun Sep 8 05:31:10 EDT 2019
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
More information about the Python-list
mailing list