@@ -367,12 +367,14 @@ def idle_draw(*args):
367
367
self ._idle = True
368
368
if d : QtCore .QTimer .singleShot (0 , idle_draw )
369
369
370
+
370
371
class MainWindow (QtGui .QMainWindow ):
371
372
def closeEvent (self , event ):
372
373
self .emit (QtCore .SIGNAL ('closing()' ))
373
374
QtGui .QMainWindow .closeEvent (self , event )
374
375
375
- class FigureManagerQT ( FigureManagerBase ):
376
+
377
+ class FigureManagerQT (FigureManagerBase ):
376
378
"""
377
379
Public attributes
378
380
@@ -382,30 +384,30 @@ class FigureManagerQT( FigureManagerBase ):
382
384
window : The qt.QMainWindow
383
385
"""
384
386
385
- def __init__ ( self , canvas , num ):
386
- if DEBUG : print ('FigureManagerQT.%s' % fn_name ())
387
- FigureManagerBase .__init__ ( self , canvas , num )
387
+ def __init__ (self , canvas , num ):
388
+ if DEBUG :
389
+ print ('FigureManagerQT.%s' % fn_name ())
390
+ FigureManagerBase .__init__ (self , canvas , num )
388
391
self .canvas = canvas
389
392
self .window = MainWindow ()
390
393
self .window .connect (self .window , QtCore .SIGNAL ('closing()' ),
391
- canvas .close_event )
392
- self .window .connect ( self .window , QtCore .SIGNAL ( 'closing()' ),
393
- self ._widgetclosed )
394
+ canvas .close_event )
395
+ self .window .connect (self .window , QtCore .SIGNAL ('closing()' ),
396
+ self ._widgetclosed )
394
397
395
398
self .window .setWindowTitle ("Figure %d" % num )
396
- image = os .path .join ( matplotlib .rcParams ['datapath' ],'images' ,'matplotlib.png' )
397
- self .window .setWindowIcon (QtGui .QIcon ( image ))
399
+ image = os .path .join (matplotlib .rcParams ['datapath' ], 'images' , 'matplotlib.png' )
400
+ self .window .setWindowIcon (QtGui .QIcon (image ))
398
401
399
402
# Give the keyboard focus to the figure instead of the
400
403
# manager; StrongFocus accepts both tab and click to focus and
401
404
# will enable the canvas to process event w/o clicking.
402
405
# ClickFocus only takes the focus is the window has been
403
406
# clicked
404
407
# on. http://developer.qt.nokia.com/doc/qt-4.8/qt.html#FocusPolicy-enum
405
- self .canvas .setFocusPolicy ( QtCore .Qt .StrongFocus )
408
+ self .canvas .setFocusPolicy (QtCore .Qt .StrongFocus )
406
409
self .canvas .setFocus ()
407
410
408
-
409
411
self .window ._destroying = False
410
412
411
413
self .toolbar = self ._get_toolbar (self .canvas , self .window )
@@ -421,7 +423,7 @@ def __init__( self, canvas, num ):
421
423
# requested size:
422
424
cs = canvas .sizeHint ()
423
425
sbs = self .window .statusBar ().sizeHint ()
424
- self ._status_and_tool_height = tbs_height + sbs .height ()
426
+ self ._status_and_tool_height = tbs_height + sbs .height ()
425
427
height = cs .height () + self ._status_and_tool_height
426
428
self .window .resize (cs .width (), height )
427
429
@@ -430,14 +432,14 @@ def __init__( self, canvas, num ):
430
432
if matplotlib .is_interactive ():
431
433
self .window .show ()
432
434
433
- def notify_axes_change ( fig ):
435
+ def notify_axes_change (fig ):
434
436
# This will be called whenever the current axes is changed
435
437
if self .toolbar is not None :
436
438
self .toolbar .update ()
437
- self .canvas .figure .add_axobserver ( notify_axes_change )
439
+ self .canvas .figure .add_axobserver (notify_axes_change )
438
440
439
441
@QtCore .Slot ()
440
- def _show_message (self ,s ):
442
+ def _show_message (self , s ):
441
443
# Fixes a PySide segfault.
442
444
self .window .statusBar ().showMessage (s )
443
445
@@ -447,8 +449,9 @@ def full_screen_toggle(self):
447
449
else :
448
450
self .window .showFullScreen ()
449
451
450
- def _widgetclosed ( self ):
451
- if self .window ._destroying : return
452
+ def _widgetclosed (self ):
453
+ if self .window ._destroying :
454
+ return
452
455
self .window ._destroying = True
453
456
try :
454
457
Gcf .destroy (self .num )
@@ -476,15 +479,19 @@ def resize(self, width, height):
476
479
def show (self ):
477
480
self .window .show ()
478
481
479
- def destroy ( self , * args ):
482
+ def destroy (self , * args ):
480
483
# check for qApp first, as PySide deletes it in its atexit handler
481
- if QtGui .QApplication .instance () is None : return
482
- if self .window ._destroying : return
484
+ if QtGui .QApplication .instance () is None :
485
+ return
486
+ if self .window ._destroying :
487
+ return
483
488
self .window ._destroying = True
484
- QtCore .QObject .disconnect ( self .window , QtCore .SIGNAL ( 'destroyed()' ),
485
- self ._widgetclosed )
486
- if self .toolbar : self .toolbar .destroy ()
487
- if DEBUG : print ("destroy figure manager" )
489
+ QtCore .QObject .disconnect (self .window , QtCore .SIGNAL ('destroyed()' ),
490
+ self ._widgetclosed )
491
+ if self .toolbar :
492
+ self .toolbar .destroy ()
493
+ if DEBUG :
494
+ print ("destroy figure manager" )
488
495
self .window .close ()
489
496
490
497
def get_window_title (self ):
0 commit comments