Next / Previous / Contents / Shipman's homepage

16.9. ColorReadout.__fixNames(): Prevent user modification of the Entry widgets

For an explanation of what this handler does and why it does it, see Section 16.7, “ColorReadout.__createWidgets(). It is called with the event handler protocol, so it expects an Event object as its argument.

# - - -   C o l o r R e a d o u t . _ _ f i x N a m e s

    def __fixNames ( self, event ):
        """Prevent the user from modifying color name Entry widgets.

These lines re-assert the two class invariants: that the self.__bgColorVar control variable reflects the background color in self.__bgColor, and the same invariant for self.__textColorVar and self.__textColor.

        self.__bgColorVar.set ( str ( self.__bgColor ) )
        self.__textColorVar.set ( str ( self.__textColor ) )