-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
BUG : modified logic on starting qApp #3360
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
Conversation
when working in ipython, it seems that _create_qApp is not called until the first time that a figure is made, but ipython has already started up the QApplication for us (I think) so that we never set backend_qt5 to be non-None. This seems to mostly be ok, but breaks `plt.pause`.
@mfitzp can you take a look at this? |
@jenshnielsen Can you review this? Test code is
in an ipython session with the matplotlib magic turned on. @ivanov Is this something that needs be looked at on the ipython side? |
Confirming that without this I see In [6]: plt.pause(3)
/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-x86_64.egg/matplotlib/backend_bases.py:2380: MatplotlibDeprecationWarning: Using default event loop until function specific to this GUI is implemented
warnings.warn(str, mplDeprecation)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-f611131acf69> in <module>()
----> 1 plt.pause(3)
/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-x86_64.egg/matplotlib/pyplot.pyc in pause(interval)
196 canvas.draw()
197 show(block=False)
--> 198 canvas.start_event_loop(interval)
199 return
200
/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-x86_64.egg/matplotlib/backends/backend_qt5.pyc in start_event_loop(self, timeout)
408
409 def start_event_loop(self, timeout):
--> 410 FigureCanvasBase.start_event_loop_default(self, timeout)
411
412 start_event_loop.__doc__ = \
/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-x86_64.egg/matplotlib/backend_bases.pyc in start_event_loop_default(self, timeout)
2386 self._looping = True
2387 while self._looping and counter * timestep < timeout:
-> 2388 self.flush_events()
2389 time.sleep(timestep)
2390 counter += 1
/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-x86_64.egg/matplotlib/backends/backend_qt5.pyc in flush_events(self)
405 def flush_events(self):
406 global qApp
--> 407 qApp.processEvents()
408
409 def start_event_loop(self, timeout):
AttributeError: 'NoneType' object has no attribute 'processEvents' However, at first attempt I could also not get it to work with your branch which I don't understand. I will do some more careful testing to figure out what is happening. |
Ok some more testing. I think I had an issue with virtual envs when i first tested it. The patch does indeed seem to resolve the issue. I have tested with homebrew python 2.7 and python 3.4 using PyQT 4.11.1 The patch definitely resolves the issue and does not seem to brake anything obvious. I am by no means an expert on QT, PyQT or the eventloop integration but it looks sensible to me. |
The Travis error is a timeout on python 3.3 so not related |
I restarted the travis server. I think this is good to merge unless there are any objections I will merge it tomorrow. |
@jenshnielsen Waiting on this PR to tag the next (and I really really hope last) RC. |
BUG : modified logic on starting qApp
Sorry, I have merged it now. I think everything should be ready |
when working in ipython, it seems that _create_qApp is not called
until the first time that a figure is made, but ipython has already
started up the QApplication for us (I think) so that we never set
backend_qt5.qApp to be non-None. This seems to mostly be ok, but breaks
plt.pause
.I don't have time right now to track down the when this bug came in and if this is something we changed or something Ipython changed.