Next / Previous / Contents / Shipman's homepage

5.5. 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 tk.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=tk.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=tk.N)