15
15
from matplotlib .figure import Figure
16
16
from matplotlib .mathtext import MathTextParser
17
17
from matplotlib .widgets import SubplotTool
18
- import matplotlib .backends .qt4_editor .figureoptions as figureoptions
18
+ try :
19
+ import matplotlib .backends .qt4_editor .figureoptions as figureoptions
20
+ except ImportError :
21
+ figureoptions = None
22
+ figureoptions = None
23
+
24
+ print figureoptions
19
25
20
26
try :
21
27
from PyQt4 import QtCore , QtGui
@@ -429,9 +435,10 @@ def _init_toolbar(self):
429
435
self .configure_subplots )
430
436
a .setToolTip ('Configure subplots' )
431
437
432
- a = self .addAction (self ._icon ("qt4_editor_options.svg" ),
433
- 'Customize' , self .edit_parameters )
434
- a .setToolTip ('Edit curves line and axes parameters' )
438
+ if figureoptions is not None :
439
+ a = self .addAction (self ._icon ("qt4_editor_options.svg" ),
440
+ 'Customize' , self .edit_parameters )
441
+ a .setToolTip ('Edit curves line and axes parameters' )
435
442
436
443
a = self .addAction (self ._icon ('filesave.svg' ), 'Save' ,
437
444
self .save_figure )
@@ -456,34 +463,35 @@ def _init_toolbar(self):
456
463
# reference holder for subplots_adjust window
457
464
self .adj_window = None
458
465
459
- def edit_parameters (self ):
460
- allaxes = self .canvas .figure .get_axes ()
461
- if len (allaxes ) == 1 :
462
- axes = allaxes [0 ]
463
- else :
464
- titles = []
465
- for axes in allaxes :
466
- title = axes .get_title ()
467
- ylabel = axes .get_ylabel ()
468
- if title :
469
- text = title
470
- if ylabel :
471
- text += ": " + ylabel
472
- text += " (%s)"
473
- elif ylabel :
474
- text = "%%s (%s)" % ylabel
475
- else :
476
- text = "%s"
477
- titles .append (text % repr (axes ))
478
- item , ok = QtGui .QInputDialog .getItem (self , 'Customize' ,
479
- 'Select axes:' , titles ,
480
- 0 , False )
481
- if ok :
482
- axes = allaxes [titles .index (unicode (item ))]
466
+ if figureoptions is not None :
467
+ def edit_parameters (self ):
468
+ allaxes = self .canvas .figure .get_axes ()
469
+ if len (allaxes ) == 1 :
470
+ axes = allaxes [0 ]
483
471
else :
484
- return
472
+ titles = []
473
+ for axes in allaxes :
474
+ title = axes .get_title ()
475
+ ylabel = axes .get_ylabel ()
476
+ if title :
477
+ text = title
478
+ if ylabel :
479
+ text += ": " + ylabel
480
+ text += " (%s)"
481
+ elif ylabel :
482
+ text = "%%s (%s)" % ylabel
483
+ else :
484
+ text = "%s"
485
+ titles .append (text % repr (axes ))
486
+ item , ok = QtGui .QInputDialog .getItem (self , 'Customize' ,
487
+ 'Select axes:' , titles ,
488
+ 0 , False )
489
+ if ok :
490
+ axes = allaxes [titles .index (unicode (item ))]
491
+ else :
492
+ return
485
493
486
- figureoptions .figure_edit (axes , self )
494
+ figureoptions .figure_edit (axes , self )
487
495
488
496
489
497
def dynamic_update ( self ):
0 commit comments