3

I call a matplotlib function plt.show() from an PyQt application. I always have the warning:

QCoreApplication::exec: The event loop is already running

It seems that matplotlib called a new QCoreApplication which is already started How can I do to remove this warning? Thanks

nam
  • 3,542
  • 9
  • 46
  • 68
  • 3
    Don't call `.show()`. It starts its own event loop. Embed your plot like in this [example](http://matplotlib.org/examples/user_interfaces/embedding_in_qt4.html). – Avaris Jan 28 '13 at 12:12

2 Answers2

5

If you are not generating multiple plots, the easiest way around is to use plt.ion() before you initialise the figure. Remove plt.show()

Sri
  • 693
  • 1
  • 9
  • 22
0

I ran into similar problems. The root cause is that your PyQt application uses Qt (which is of course obvious). But the matplotlib figure you're trying to make, also uses Qt. You know, the matplotlib figure has its own window, which originates from Qt. So there is a conflict.

Approach 1

There are several ways to solve it. One approach is explained here:

Matplotlib animation inside your own PyQt4 GUI

The link refers you to a stackoverflow question I've put online some days ago. I was trying to start a matplotlib animation from my own PyQt application.

Approach 2 The second approach is explained here:

Cannot move Matplotlib plot window and exit it using red X button

I hope this helped you out. If you've got any questions, don't hesitate to ask me. I'm happy to help.

Community
  • 1
  • 1
K.Mulier
  • 8,069
  • 15
  • 79
  • 141