@@ -208,18 +208,6 @@ def __init__( self, figure ):
208
208
w ,h = self .get_width_height ()
209
209
self .resize ( w , h )
210
210
211
- # JDH: Note the commented out code below does not work as
212
- # expected, because according to Pierre Raybaut, The reason is
213
- # that PyQt fails (silently) to call a method of this object
214
- # just before detroying it. Using a lambda function will work,
215
- # exactly the same as using a function (which is not bound to
216
- # the object to be destroyed).
217
- #
218
- #QtCore.QObject.connect(self, QtCore.SIGNAL('destroyed()'),
219
- # self.close_event)
220
- QtCore .QObject .connect (self , QtCore .SIGNAL ('destroyed()' ),
221
- lambda : self .close_event ())
222
-
223
211
def __timerEvent (self , event ):
224
212
# hide until we can test and fix
225
213
self .mpl_idle_event (event )
@@ -379,6 +367,10 @@ def idle_draw(*args):
379
367
self ._idle = True
380
368
if d : QtCore .QTimer .singleShot (0 , idle_draw )
381
369
370
+ class MainWindow (QtGui .QMainWindow ):
371
+ def closeEvent (self , event ):
372
+ self .emit (QtCore .SIGNAL ('closing()' ))
373
+
382
374
class FigureManagerQT ( FigureManagerBase ):
383
375
"""
384
376
Public attributes
@@ -393,8 +385,9 @@ def __init__( self, canvas, num ):
393
385
if DEBUG : print ('FigureManagerQT.%s' % fn_name ())
394
386
FigureManagerBase .__init__ ( self , canvas , num )
395
387
self .canvas = canvas
396
- self .window = QtGui .QMainWindow ()
397
- self .window .setAttribute (QtCore .Qt .WA_DeleteOnClose )
388
+ self .window = MainWindow ()
389
+ self .window .connect (self .window , QtCore .SIGNAL ('closing()' ),
390
+ canvas .close_event )
398
391
399
392
self .window .setWindowTitle ("Figure %d" % num )
400
393
image = os .path .join ( matplotlib .rcParams ['datapath' ],'images' ,'matplotlib.png' )
@@ -621,7 +614,6 @@ def draw_rubberband( self, event, x0, y0, x1, y1 ):
621
614
def configure_subplots (self ):
622
615
self .adj_window = QtGui .QMainWindow ()
623
616
win = self .adj_window
624
- win .setAttribute (QtCore .Qt .WA_DeleteOnClose )
625
617
626
618
win .setWindowTitle ("Subplot Configuration Tool" )
627
619
image = os .path .join ( matplotlib .rcParams ['datapath' ],'images' ,'matplotlib.png' )
0 commit comments