codehaus


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


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