[IPython-user] display hook

Peter Waller peter.waller@gmail....
Wed May 27 07:18:01 CDT 2009


My temporary (nasty) workaround, as opposed to using set_hook():


        from IPython.Prompts import CachedOutput
        oldCall = CachedOutput.__call__
        def DisplayHook(*args):
            R.gInterpreter.EndOfLineAction() # Update graphics
            return oldCall(*args)
        CachedOutput.__call__ = DisplayHook

2009/5/27 Peter Waller <peter.waller@gmail.com>

> Dear list,
>
> I am trying to use IPython with a package called ROOT, and I am having
> problems with interfering display hooks. ROOT uses sys.displayhook to ensure
> that graphics are uptodate after a command is run in the interactive prompt.
> This works fine so long as ROOT is imported after IPython is started up, but
> if ROOT is imported before IPython, then IPython sets its own display hook.
>
> This wouldn't be a problem if IPython ran the displayhook no matter what,
> but it is conditional on whether the thing to be displayed is 'None'. If it
> is none, then the display hooks are not called. Since many of the functions
> which want to update a graphic display are returning None, my graphics are
> not being updated.
>
> In IPython version 0.9.1 line 533 of Prompts.py in the __call__ method of
> CachedOutput, reads "if arg is not None:", and under that if statement is
> the statement "manipulated_val = self.display(arg)". I believe that
> self.display(arg) should be called even if arg is None, so that displayhooks
> can be used to update graphics.
>
> Please let me know what you think,
>
> Regards,
>
> - Peter
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20090527/4d90e0b4/attachment.html 


More information about the IPython-user mailing list