예제 #1
0
    def wrapper(*args, **kwargs):

        if len(DEFER_DRAW_BACKENDS) == 0:
            return func(*args, **kwargs)

        # Don't recursively defer draws. We just check the first draw_idle
        # method since all should be modified in sync.
        if isinstance(DEFER_DRAW_BACKENDS[0].draw_idle, DeferredMethod):
            return func(*args, **kwargs)

        try:
            for backend in DEFER_DRAW_BACKENDS:
                backend.draw_idle = DeferredMethod(backend.draw_idle)
            result = func(*args, **kwargs)
        finally:
            for backend in DEFER_DRAW_BACKENDS:
                # We need to use another try...finally block here in case the
                # executed deferred draw calls fail for any reason
                try:
                    try:
                        backend.draw_idle.execute_deferred_calls()
                    except RuntimeError:  # For C/C++ errors with Qt
                        pass
                finally:
                    backend.draw_idle = backend.draw_idle.original_method

        return result
예제 #2
0
    def wrapper(*args, **kwargs):

        from matplotlib.backends.backend_agg import FigureCanvasAgg

        # don't recursively defer draws
        if isinstance(FigureCanvasAgg.draw, DeferredMethod):
            return func(*args, **kwargs)

        try:
            FigureCanvasAgg.draw = DeferredMethod(FigureCanvasAgg.draw)
            result = func(*args, **kwargs)
        finally:
            FigureCanvasAgg.draw.execute_deferred_calls()
            FigureCanvasAgg.draw = FigureCanvasAgg.draw.original_method
        return result
예제 #3
0
    def wrapper(*args, **kwargs):

        from matplotlib.backends.backend_agg import FigureCanvasAgg

        # don't recursively defer draws
        if isinstance(FigureCanvasAgg.draw, DeferredMethod):
            return func(*args, **kwargs)

        try:
            FigureCanvasAgg.draw = DeferredMethod(FigureCanvasAgg.draw)
            result = func(*args, **kwargs)
        finally:
            # We need to use another try...finally block here in case the
            # executed deferred draw calls fail for any reason
            try:
                FigureCanvasAgg.draw.execute_deferred_calls()
            finally:
                FigureCanvasAgg.draw = FigureCanvasAgg.draw.original_method
        return result