Hi all! The QT backend (backend_qt.py) does not enter QT's event loop when multiple figures were created. It works fine with a single figure though.
I have tested this with Suse Linux 10.2. matplotlib.__version__ : 0.90.1 I have attached a little test program that illustrates the bug: When this program is run, two windows will appear for a split second, and the program finishes immediately. When lines 10 and 11 are commented out, the program works as expected: One window with a figure appears, and the program finishes when the window is closed. The attached patch fixes this bug. It is against the current HEAD in trunk. >From reading the code, the exact same fix should be done in the QT4 backend. Regards, Eike.
mpl-test.py
Description: application/python
Index: matplotlib/lib/matplotlib/backends/backend_qt.py
===================================================================
--- matplotlib/lib/matplotlib/backends/backend_qt.py (revision 3873)
+++ matplotlib/lib/matplotlib/backends/backend_qt.py (working copy)
@@ -46,11 +46,14 @@
qApp = qt.QApplication( [" "] )
qt.QObject.connect( qApp, qt.SIGNAL( "lastWindowClosed()" ),
qApp, qt.SLOT( "quit()" ) )
- else:
+ #remember that matplotlib created the qApp - will be used by show()
+ _create_qApp.qAppCreatedHere = True
+ # else:
# someone else aready created the qApp and
# we let them handle the event-loop control.
- show._needmain = False
+_create_qApp.qAppCreatedHere = False
+
def show():
"""
Show all the figures and enter the qt main loop
@@ -65,13 +68,11 @@
if figManager != None:
figManager.canvas.draw()
- if ( show._needmain ):
+ if _create_qApp.qAppCreatedHere:
+ #only start event loop if matplotlib created the qApp
qt.qApp.exec_loop()
- show._needmain = False
-show._needmain = True
-
def new_figure_manager( num, *args, **kwargs ):
"""
Create a new figure manager instance
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________ Matplotlib-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
