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 , Qt
@@ -424,9 +430,10 @@ def _init_toolbar(self):
424
430
self .configure_subplots )
425
431
a .setToolTip ('Configure subplots' )
426
432
427
- a = self .addAction (self ._icon ("qt4_editor_options.svg" ),
428
- 'Customize' , self .edit_parameters )
429
- a .setToolTip ('Edit curves line and axes parameters' )
433
+ if figureoptions is not None :
434
+ a = self .addAction (self ._icon ("qt4_editor_options.svg" ),
435
+ 'Customize' , self .edit_parameters )
436
+ a .setToolTip ('Edit curves line and axes parameters' )
430
437
431
438
a = self .addAction (self ._icon ('filesave.svg' ), 'Save' ,
432
439
self .save_figure )
@@ -451,34 +458,35 @@ def _init_toolbar(self):
451
458
# reference holder for subplots_adjust window
452
459
self .adj_window = None
453
460
454
- def edit_parameters (self ):
455
- allaxes = self .canvas .figure .get_axes ()
456
- if len (allaxes ) == 1 :
457
- axes = allaxes [0 ]
458
- else :
459
- titles = []
460
- for axes in allaxes :
461
- title = axes .get_title ()
462
- ylabel = axes .get_ylabel ()
463
- if title :
464
- text = title
465
- if ylabel :
466
- text += ": " + ylabel
467
- text += " (%s)"
468
- elif ylabel :
469
- text = "%%s (%s)" % ylabel
470
- else :
471
- text = "%s"
472
- titles .append (text % repr (axes ))
473
- item , ok = QtGui .QInputDialog .getItem (self , 'Customize' ,
474
- 'Select axes:' , titles ,
475
- 0 , False )
476
- if ok :
477
- axes = allaxes [titles .index (unicode (item ))]
461
+ if figureoptions is not None :
462
+ def edit_parameters (self ):
463
+ allaxes = self .canvas .figure .get_axes ()
464
+ if len (allaxes ) == 1 :
465
+ axes = allaxes [0 ]
478
466
else :
479
- return
467
+ titles = []
468
+ for axes in allaxes :
469
+ title = axes .get_title ()
470
+ ylabel = axes .get_ylabel ()
471
+ if title :
472
+ text = title
473
+ if ylabel :
474
+ text += ": " + ylabel
475
+ text += " (%s)"
476
+ elif ylabel :
477
+ text = "%%s (%s)" % ylabel
478
+ else :
479
+ text = "%s"
480
+ titles .append (text % repr (axes ))
481
+ item , ok = QtGui .QInputDialog .getItem (self , 'Customize' ,
482
+ 'Select axes:' , titles ,
483
+ 0 , False )
484
+ if ok :
485
+ axes = allaxes [titles .index (unicode (item ))]
486
+ else :
487
+ return
480
488
481
- figureoptions .figure_edit (axes , self )
489
+ figureoptions .figure_edit (axes , self )
482
490
483
491
484
492
def dynamic_update ( self ):
0 commit comments