code: def register_event(self, event_type, pattern, handler):
          
          if event_type not in self._supported_events:
              raise ValueError("Unsupported event type {}".format(event_type))
          if event_type != "CHANGE" and not isinstance(pattern, Pattern) and not isinstance(pattern, basestring):
              raise ValueError("Expected pattern to be a Pattern or string")
          if event_type == "CHANGE" and not (len(pattern)==2 and isinstance(pattern[0], int) and isinstance(pattern[1], numpy.ndarray)):
              raise ValueError("For \"CHANGE\" events, ``pattern`` should be a tuple of ``min_changed_pixels`` and the base screen state.")
  
          # Create event object
          event = {
              "pattern": pattern,
              "event_type": event_type,
              "count": 0,
              "handler": handler,
              "name": uuid.uuid4(),
              "active": True
          }
          self._events[event["name"]] = event
          return event["name"]
docs: When ``event_type`` is observed for ``pattern``, triggers ``handler``.
  
          For "CHANGE" events, ``pattern`` should be a tuple of ``min_changed_pixels`` and
          the base screen state.