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

7.2. Controls.__createWidgets()

For details of the layout and grid plans, see Section 7, “class Controls: Controls frame”.

fontselect.py
    def __createWidgets ( self ):
        """Widget layout.
        """

First we set up the three items gridded in self.

fontselect.py
        #-- 1 --
        # [ self  :=  self with a new Label added and gridded
        #             with a string control variable
        #   self.annunciator  :=  that Label
        #   self.__fontName   :=  that control variable ]
        self.__fontName  =  StringVar()
        self.annunciator  =  Label ( self,
            font=self.fontSelect.regularFont, 
            textvariable=self.__fontName,
            text="" )
        rowx  =  0
        self.annunciator.grid ( row=rowx, sticky=W )

The width and height options of the Text widget are in lines and characters, respectively. This gives a bit of room for the user to add or change text.

fontselect.py
        #-- 2 --
        # [ self  :=  self with a new Text widget added and gridded,
        #             displaying SAMPLE_TEXT
        #   self.sample  :=  that widget ]
        self.sample  =  Text ( self,
            width=20, height=2,
            font=self.fontSelect.regularFont )
        rowx  +=  1
        self.sample.grid ( row=rowx, sticky=W )
        self.sample.insert ( END, SAMPLE_TEXT )

The self.buttons frame is made to stick to the left (west) side of the containing column by using sticky=W when it is gridded.

fontselect.py
        #-- 3 --
        # [ self  :=  self with a new Frame widget added and gridded
        #   self.buttons  :=  that widget ]
        self.buttons  =  Frame ( self )
        rowx  +=  1
        self.buttons.grid ( row=rowx, sticky=W )

The creation and gridding of the remaining controls is done in Section 7.3, “Controls.__createButtons(): Lay out the small controls frame”.

fontselect.py
        #-- 4 --
        # [ self  :=  self with .sizeLabel, .sizeField, .sizeButton,
        #       .boldButton, and .italicButton added and gridded ]
        self.__createButtons()