New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue with display hook in base python repl #4504
Comments
With the repl callback the pyplot function do not need to call `draw_if_interactive`.
Another option may be to hook |
copied from commit thread: If we tie this to the state change of stale on the Figure, it will only get flipped to True once so there should only be one call to draw_if_interactive/draw_idle anyway. My current inclination is to change the repl registration to use the IPython hooks if they are available and the Figure-based callback otherwise. I will take a crack at this tomorrow morning. |
If we do not have IPython, then the only hook I know of in the repl is the display hook which is called when ever something is going to be displayed, not after the execution of the last command has finished (the reason it exists is to give users a chance to intercept and change the display of the output, not as a generic call back as we were trying to use it). In this case register a callback on the `Figure` artist at creation time to call `draw_idle` on the canvas if the Figure is stale. We are guaranteed to see this at least once when stale is flipped to True, but may see it more than once if other paths call `pchanged()`. Fortunately, `pchanged` is not widely used in the internal code base and even if `draw_idle` is called multiple times, we should be able to count on the backends handling multiple draw_idle commands correctly. Closes matplotlib#4504
Something I just noticed when playing around with the interactive mode in
|
Sure, but that's expected behaviour right? The same happens with |
This only applies to the base
python
repl, everything works inIPython
repls.In discussion on b2fbae7 discovered that
sys.displayhook
only gets evaluated for expressions, not statements.This means that things like
will not trigger the auto-redrawing. This is particularly troubling because this mean
will not trigger a re-draw, but
will.
Due to b2fbae7, where we rely on the auto-redrawing to trigger the
pyplot
redrawing this means that manypyplot
workflows in the normal repl are broken (as in things that used to auto-redraw no longer do).The options I think are:
draw_if_interactive
which maintains some functions as 'special'I suspect that the answer is going to be both 2 and 3. normal python shell keeps current functionality and gains some new functionality, IPython picks up lots of new functionality, and the code base keeps this particular wart.
The text was updated successfully, but these errors were encountered: