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

13.3. NamePicker.__entryHandler(): Handler for the Enter key

This method is called when the user presses the Enter key in the color name field. Assuming the color name is valid, we then call the class's callback to notify observers that the color has changed.

huey
# - - -   N a m e P i c k e r . _ _ e n t r y H a n d l e r

    def __entryHandler ( self, event ):
        """Handle the Enter key in the color name field.

          [ event is an Event from self.__entry ->
              if  self.__entryVar is a valid color name ->
                call self.__callback with a Color representing
                that name
              else ->
                pop up a Dialog informing the user that the
                color name is not valid ]
        """

The .get() method on self.__entryVar retrieves the text from the color name field. We then pass the name on to Section 13.4, “NamePicker.__setByName(): Try to convert a color name to a color”.

huey
        #-- 1 --
        # [ colorName  :=  text from self.__entryVar ]
        colorName  =  self.__entryVar.get()

        #-- 2 --
        # [ if  self.__entryVar is a valid color name ->
        #     call self.__callback with a Color representing
        #     that name
        #   else ->
        #     pop up a Dialog informing the user that the
        #     color name is not valid ]
        self.__setByName ( colorName )