[Tutor] Tkinter layout question

Phil phil_lor at bigpond.com
Sun Apr 23 18:49:54 EDT 2017


On Sun, 23 Apr 2017 11:28:51 +0200
Peter Otten <__peter__ at web.de> wrote:

> Consider the function make_a_cake(). If you use it
> 
> eat_a_piece_of(make_a_cake())
> eat_a_piece_of(make_a_cake())
> 
> that's short for
> 
> one_cake = make_a_cake()
> eat_a_piece_of(one_cake)
> 
> another_cake = make_a_cake()
> eat_a_piece_of(another_cake)
> 
> i. e. you had two pieces of cake, one piece of each of two cakes.
> 
> If you write
> 
> cake = make_a_cake()
> eat_a_piece_of(cake)
> eat_a_piece_of(cake)
> 
> you have still eaten two pieces of cake but both are taken from the
> same cake.
> 
> Likewise when you write
> 
> root = tk.Tk()
> first_table = DisplayTable(root)
> second_table = DisplayTable(root)
> 
> both tables share the same instance of the Tk class.
>  
> > Also I found that root.mainloop() isn't necessary in that the
> > result is the same with or without. Perhaps it serves some other
> > purpose?
> 
> Try running it from the command line, not in idle. In every tkinter
> program there must be a main loop to respond to events.

Thank you again Peter for taking the time to answer my question.

-- 
Regards,
Phil


More information about the Tutor mailing list