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

16.6. ColorReadout.__init__(): Constructor

The constructor first calls it parent class constructor to make it into a Frame. Then it creates the control variable .__isTextVar, and set it initially to indicate the background color. Finally it calls Section 16.7, “ColorReadout.__createWidgets() to create and position its contained widgets.

huey
# - - -   C o l o r R e a d o u t . _ _ i n i t _ _

    def __init__ ( self, parent, bg, fg, callback=None ):
        """Constructor for ColorReadout.
        """

        #-- 1 --
        # [ parent  :=  parent with self added as a new Frame ]
        Frame.__init__ ( self, parent, relief=SUNKEN, bd=4 )

        #-- 2 --
        # [ self.__isTextVar  :=  a new IntVar control variable
        #                         initialized to 0
        #   self.__bgColor  :=  bg
        #   self.__bgColorVar  :=  a new StringVar control
        #       variable set to str(bg)
        #   self.__textColor  :=  fg
        #   self.__textColorVar  :=  a new StringVar control
        #       variable set to str(fg) ]
        self.__isTextVar  =  IntVar()
        self.__isTextVar.set(0)
        self.__bgColor  =  bg
        self.__bgColorVar  =  StringVar()
        self.__bgColorVar.set ( str ( bg ) )
        self.__textColor  =  fg
        self.__textColorVar  =  StringVar()
        self.__textColorVar.set ( str ( fg ) )

        #-- 3 --
        # [ self  :=  self with all internal widgets created and
        #             gridded ]
        self.__createWidgets()

        #-- 4 --
        self.__callback  =  callback