Skip to content Skip to sidebar Skip to footer

Event Lag In Matplotlib Mpl_connect When Run From Ipython Shell

I am attempting to write a very simple little 'gui' which will allow the user to click on an image and have the position and the value printed to the screen. What I have works, bu

Solution 1:

Well, I managed to track this down - it turns out that this is an known issue with QtConsole, and the underlying cause is the same as this question (both Canopy and Spyder use ipython qtconsole in their GUIs). The issue is that the first print doesn't trigger a flush of stdout (a much better explanation from a couple years ago can be found here), so you have to a) do it manually, as below, or b) use ipython -u for unbuffered output, which I haven't tried. Flushing manually will work fine for me, so I'll go with that for now.

If I add the following to my code it works as expected:

import sys

# (put this after the print statement)
sys.stdout.flush()

Post a Comment for "Event Lag In Matplotlib Mpl_connect When Run From Ipython Shell"