def event_handling(self):
        """Handle events from the event queue."""
        ### iterate over the events in the event queue,
        ### processing the relevant ones according to their
        ### settings

        for event in SERVICES_NS.get_events():

            ### quit the application
            if event.type == QUIT:
                self.quit()

            ### if one of the following keys is released,
            ### turn on the the 'cancel' flag and trigger
            ### the exit of the loop

            elif event.type == KEYUP:

                if event.key in (K_ESCAPE, K_RETURN, K_KP_ENTER):

                    self.cancel = True
                    self.exit_loop()

            ### if the mouse left button is release,
            ### execute the corresponding operation
            ### with the event object

            elif event.type == MOUSEBUTTONUP:
                if event.button == 1:
                    self.on_mouse_release(event)

            ### if the mouse moves, execute the
            ### corresponding operation with the event
            ### object

            elif event.type == MOUSEMOTION:
                self.on_mouse_motion(event)
Handle events from the event queue.
nodezator/colorsman/picker/op.py