[Tutor] Tkinter query?

Kent Johnson kent37 at tds.net
Wed Jul 13 14:29:43 CEST 2005


Dave S wrote:
>>But I do not understand where Frame fits in to this ... ie
>>
> 
>>from Tkinter import *
> 
>>class Hello(Frame):
>>  
>>   def __init__(self, parent=None):
>>       Frame.__init__(self, parent)
>>       self.pack()
>>
>>
>>Why not just use 'class Hello(root)' ? Or have I missed the point :-[
> 
> OK am I right in thinging a 'Frame' always has a parent of a Tk() or
> possibly Toplevel() and its used to help in positioning a widget window
> with .pack() ?

Yes, that is one use of Frame - to help with positioning groups of widgets. A Frame subclass also can be used to package a group of widgets as a reusable whole and as a place to put controller code that makes a group of widgets work together.

Kent



More information about the Tutor mailing list