class TestKeyEvents:

    def key_down(self, event):
        which = self.which_key(event)
        if event.auto:
            print "Auto key:", which
        else:
            print "Key down:", which
    
    def key_up(self, event):
        print "Key up:", self.which_key(event)
    
    def which_key(self, event):
        return repr(event.key or event.char)


class TestMouseEvents:
    
    def mouse_down(self, event):
        self.report_mouse_event(
            "Mouse down: %s button: %s clicks: %s" % (event.position, event.button, event.num_clicks))

    def mouse_drag(self, event):
        self.report_mouse_event("Mouse drag: %s" % (event.position,))

    def mouse_up(self, event):
        self.report_mouse_event("Mouse up: %s button: %s" % (event.position, event.button))

    def mouse_move(self, event):
        self.report_mouse_event("Mouse move: %s" % (event.position,))

    def mouse_enter(self, event):
        self.report_mouse_event("Mouse enter: %s" % (event.position,))

    def mouse_leave(self, event):
        self.report_mouse_event("Mouse leave: %s" % (event.position,))
    
    def report_mouse_event(self, mess):
        print mess


class TestTrackMouse:

    def mouse_down(self, event):
        print "Mouse down:", event.position
        for event in self.track_mouse():
            if event.kind == 'mouse_drag':
                print "Mouse drag:", event.position
            elif event.kind == 'mouse_up':
                print "Mouse up:", event.position
            else:
                print "Other event:", event.kind
