Next / Previous / Contents / Shipman's homepage

5.5. ScrolledList.__init__(): Constructor

The constructor defines default values for all the keyword arguments. Note that the vertical scrollbar is on by default, while the horizontal scrollbar is off by default. See Section 5.3.1, “DEFAULT_WIDTH: Default list width” and Section 5.3.2, “DEFAULT_HEIGHT: Default list height”.

scrolledlist.py
    def __init__(self, master=None, width=DEFAULT_WIDTH,
                 height=DEFAULT_HEIGHT, vscroll=1, hscroll=0,
                 callback=None):
        """Constructor for ScrolledList.
        """

The constructor's first job is to call the constructor for its parent class, Frame.

scrolledlist.py
        #-- 1
        # [ self  :=  a new Frame widget child of master ]
        tk.Frame.__init__(self, master)

Next, we store the various constructor arguments inside the instance.

scrolledlist.py
        #-- 2
        self.width    = width
        self.height   = height
        self.vscroll  = vscroll
        self.hscroll  = hscroll
        self.callback = callback

Finally, we lay out the internal widgets.

scrolledlist.py
        #-- 3
        # [ self  :=  self with all widgets created and registered ]
        self.__createWidgets()