Skip to content
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

BUG : modified logic on starting qApp #3360

Merged
merged 1 commit into from Aug 17, 2014

Conversation

tacaswell
Copy link
Member

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.

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`.
@tacaswell tacaswell added this to the v1.4.0 milestone Aug 10, 2014
@tacaswell
Copy link
Member Author

@mfitzp can you take a look at this?

@tacaswell
Copy link
Member Author

@jenshnielsen Can you review this?

Test code is

plt.gca()
plt.pause(3)

in an ipython session with the matplotlib magic turned on.

@ivanov Is this something that needs be looked at on the ipython side?

@jenshnielsen
Copy link
Member

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.

@jenshnielsen
Copy link
Member

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.

@jenshnielsen
Copy link
Member

The Travis error is a timeout on python 3.3 so not related

@jenshnielsen
Copy link
Member

I restarted the travis server. I think this is good to merge unless there are any objections I will merge it tomorrow.

@tacaswell
Copy link
Member Author

@jenshnielsen Waiting on this PR to tag the next (and I really really hope last) RC.

jenshnielsen added a commit that referenced this pull request Aug 17, 2014
BUG : modified logic on starting qApp
@jenshnielsen jenshnielsen merged commit c7af9bc into matplotlib:v1.4.x Aug 17, 2014
@jenshnielsen
Copy link
Member

Sorry, I have merged it now. I think everything should be ready

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants