Next / Previous / Contents / TCC Help System / NM Tech homepage

5.3. FontSelect.__createWidgets(): Widget placement

This method creates and grids the sub-widgets. It also sets up the control linkage that allows selection of a font family in the FamilyPicker to change the font displayed in the Controls.

fontselect.py
    def __createWidgets ( self ):
        """Create sub-widgets.

          [ self is a Frame ->
              self  :=  self with all widgets and control linkages ]
        """

The FamilyPicker constructor needs two fonts (regular and list) and our handler for change of family.

fontselect.py
        #-- 1 --
        # [ self  :=  self with a new FamilyPicker widget added
        #       and gridded that calls self.__familyHandler when
        #       a family is selected
        #   self.familyPicker  :=  that widget
        #   self.scrollList  :=  the .scrollList attribute of
        #                        that widget ]
        self.familyPicker  =  FamilyPicker ( self, self.__familyHandler )
        self.familyPicker.grid ( row=0, column=0, sticky=N )
        self.scrollList  =  self.familyPicker.scrollList

        #-- 2 --
        # [ self  :=  self with a new Controls widget added and
        #             gridded, that calls self.__controlHandler
        #             when the font changes
        #   self.controls  :=  that widget
        self.controls  =  Controls ( self, self.__controlHandler )
        self.controls.grid ( row=0, column=1, sticky=N )