def patterns_exit_mode(self):
        """Exit operation for the patterns mode."""
        ### if the pattern option menu is listed
        ### among the buttons, it means objects related
        ### to the pattern mode are present in the
        ### collections for buttons and labels, so remove
        ### such objects

        if self.pattern_options in self.buttons:

            ## remove label
            self.labels.remove(self.pattern_label)

            ## remove option menu and redraw button

            for obj in (
                self.pattern_options,
                self.redraw_pattern_button,
            ):
                self.buttons.remove(obj)

        ### perform the operation stored in the
        ### 'close_generator' attribute, which might be
        ### an empty function or actually close a previously
        ### created generator
        self.close_generator()

        ### reset the 'close_generator' attribute to an
        ### empty function
        self.close_generator = empty_function
Exit operation for the patterns mode.
nodezator/colorsman/viewer/modes/patterns/main.py