##// END OF EJS Templates
Backport PR #5459: Fix interact animation page jump FF...
Backport PR #5459: Fix interact animation page jump FF Firefox doesn't render images immediately as the data is available. When animating the way that we animate, this causes the output area to collapse quickly before returning to its original size. When the output area collapses, FireFox scrolls upwards in attempt to compensate for the lost vertical content (so it looks like you are on the same spot in the page, with respect to the contents below the image's prior location). The solution is to resize the image output after the `img onload` event has fired. This PR: - Releases the `clear_output` height lock after the image has been loaded (instead of immediately or using a timeout). - Removes a `setTimeout` call in the `append_output` method. - `clear_output` in zmqshell no longer sends `\r` to the stream outputs. closes #5128

File last commit:

r5390:c82649ea
r16229:ff1462d3
Show More
display_trap.py
70 lines | 2.1 KiB | text/x-python | PythonLexer
Brian Granger
sys.displayhook is now managed dynamically by display_trap.
r2231 # encoding: utf-8
"""
A context manager for handling sys.displayhook.
Authors:
* Robert Kern
* Brian Granger
"""
#-----------------------------------------------------------------------------
Matthias BUSSONNIER
update copyright to 2011/20xx-2011...
r5390 # Copyright (C) 2008-2011 The IPython Development Team
Brian Granger
sys.displayhook is now managed dynamically by display_trap.
r2231 #
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
import sys
Brian Granger
First draft of refactored Component->Configurable.
r2731 from IPython.config.configurable import Configurable
Brian Granger
Adding support for HasTraits to take keyword arguments.
r2740 from IPython.utils.traitlets import Any
Brian Granger
sys.displayhook is now managed dynamically by display_trap.
r2231
#-----------------------------------------------------------------------------
# Classes and functions
#-----------------------------------------------------------------------------
Brian Granger
First draft of refactored Component->Configurable.
r2731 class DisplayTrap(Configurable):
Brian Granger
sys.displayhook is now managed dynamically by display_trap.
r2231 """Object to manage sys.displayhook.
This came from IPython.core.kernel.display_hook, but is simplified
(no callbacks or formatters) until more of the core is refactored.
"""
Brian Granger
Adding support for HasTraits to take keyword arguments.
r2740 hook = Any
def __init__(self, hook=None):
super(DisplayTrap, self).__init__(hook=hook, config=None)
Brian Granger
sys.displayhook is now managed dynamically by display_trap.
r2231 self.old_hook = None
Brian Granger
Massive refactoring of of the core....
r2245 # We define this to track if a single BuiltinTrap is nested.
# Only turn off the trap when the outermost call to __exit__ is made.
self._nested_level = 0
Brian Granger
sys.displayhook is now managed dynamically by display_trap.
r2231
def __enter__(self):
Brian Granger
Massive refactoring of of the core....
r2245 if self._nested_level == 0:
self.set()
self._nested_level += 1
Brian Granger
sys.displayhook is now managed dynamically by display_trap.
r2231 return self
def __exit__(self, type, value, traceback):
Brian Granger
Massive refactoring of of the core....
r2245 if self._nested_level == 1:
self.unset()
self._nested_level -= 1
Brian Granger
The pretty.py extension has been ported to the new extension API....
r2281 # Returning False will cause exceptions to propagate
return False
Brian Granger
sys.displayhook is now managed dynamically by display_trap.
r2231
def set(self):
"""Set the hook."""
if sys.displayhook is not self.hook:
self.old_hook = sys.displayhook
sys.displayhook = self.hook
def unset(self):
"""Unset the hook."""
sys.displayhook = self.old_hook