def is_window_closed(self):
        """Try to determine if the user closed the window (by clicking the x).

        This may only work with OpenCV 3.x.

        All OpenCV window properties should return -1.0 for windows that are closed.
        If we read a property that has a value < 0 or an exception is raised we assume
        the window has been closed. We use the aspect ratio property but it could be any.

        """
        try:
            prop_asp = cv2.getWindowProperty(self._window_name, cv2.WND_PROP_ASPECT_RATIO)
            if prop_asp < 0.0:
                # the property returned was < 0 so assume window was closed by user
                return True
        except:
            return True

        return False
Try to determine if the user closed the window (by clicking the x).

        This may only work with OpenCV 3.x.

        All OpenCV window properties should return -1.0 for windows that are closed.
        If we read a property that has a value < 0 or an exception is raised we assume
        the window has been closed. We use the aspect ratio property but it could be any.

        
apps/mnist_calc/mnist_calc.py