Learning tkinter - a grid problem

Terry Reedy tjreedy at udel.edu
Mon Dec 7 00:59:12 EST 2020


On 12/6/2020 5:59 AM, Terry Reedy wrote:
> On 12/6/2020 3:11 AM, Sibylle Koczian wrote:
>> Am 05.12.2020 um 19:56 schrieb Paulo da Silva:
> 
>>> Why this example does not work?
>>> ------------------
>>> from tkinter import *
>>>
>>> root=Tk()
>>> root.geometry("400x200")
>>> S=Scrollbar(root)
>>> T=Text(root)
>> ...
>>> mainloop()
> 
>> Shouldn't that be
>> root.mainloop()
>> ?
> 
> Yes.  The * import does not turn method into module functions.

But no, sort of.  MRAB is correct that there is (an undocumented) module 
function by the same name.  It calls tkinter._default_root.tk.mainloop 
if _default_root is not None.  This is true if 
tkinter._support_default_root == 1 (the default, but set to 0 in IDLE) 
and tkinter.Tk has been called at least once.

-- 
Terry Jan Reedy




More information about the Python-list mailing list