Maintaining 'focus' on Leap Motion Python (IDLE) code execution
Question: When executing Leap-Motion-centric code in the Python IDLE, switching to
another window makes the IDLE disregard the Leap controller and stop
processing `frame`s. How can this be avoided so that, say, the Leap gestures
can be used to interact with other windows?

Not really relevant, but code to reproduce this problem:

    
    
    import Leap
    from Leap import *
    
    class FocusListener(Leap.Listener):
        def on_frame(self, controller):
            frame = controller.frame()
            print frame
    
    def main():
        # Create a sample listener and controller
        listener = FocusListener()
        controller = Leap.Controller()
    
        controller.add_listener(listener)
    
        while (1):
            listener.on_frame(controller)
    
    
    if __name__ == "__main__":
        main()
    

PS: Might this have something to do with the fact that I'm 'synthetically'
looping the frame with the `while`?


Answer: To get frames while your app isn't focused, you need to set the "background
frames" policy:

    
    
    controller.set_policy_flags(Leap.Controller.POLICY_BACKGROUND_FRAMES);
    

See:
<https://developer.leapmotion.com/documentation/python/api/Leap.Controller.html#Leap.Controller.set_policy_flags>

