Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 598afe3

Browse files
committed
Merge branch 'v1.0.x' of github.com:matplotlib/matplotlib into v1.0.x
2 parents 4c9dcba + 8d86fa3 commit 598afe3

File tree

1 file changed

+38
-30
lines changed

1 file changed

+38
-30
lines changed

lib/matplotlib/backends/backend_qt4.py

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515
from matplotlib.figure import Figure
1616
from matplotlib.mathtext import MathTextParser
1717
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
1925

2026
try:
2127
from PyQt4 import QtCore, QtGui, Qt
@@ -424,9 +430,10 @@ def _init_toolbar(self):
424430
self.configure_subplots)
425431
a.setToolTip('Configure subplots')
426432

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')
430437

431438
a = self.addAction(self._icon('filesave.svg'), 'Save',
432439
self.save_figure)
@@ -451,34 +458,35 @@ def _init_toolbar(self):
451458
# reference holder for subplots_adjust window
452459
self.adj_window = None
453460

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]
478466
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
480488

481-
figureoptions.figure_edit(axes, self)
489+
figureoptions.figure_edit(axes, self)
482490

483491

484492
def dynamic_update( self ):

0 commit comments

Comments
 (0)