From a2ca5eb8a45c9134da85697a2da84e336b9a4dc7 Mon Sep 17 00:00:00 2001 From: blitzman Date: Sat, 11 Feb 2017 10:55:09 -0500 Subject: [PATCH] fix oops --- gui/graphFrame.py | 18 +++++++++++------- gui/mainFrame.py | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/gui/graphFrame.py b/gui/graphFrame.py index bcc43b32e..2d66c4f8e 100644 --- a/gui/graphFrame.py +++ b/gui/graphFrame.py @@ -52,20 +52,26 @@ class GraphFrame(wx.Frame): global graphFrame_enabled global mplImported + self.Patch = None + self.mpl_version = -1 + try: import matplotlib as mpl - if int(mpl.__version__[0]) >= 2: + self.mpl_version = int(mpl.__version__[0]) + if self.mpl_version >= 2: mpl.use('wxagg') mplImported = True - from matplotlib.patches import Patch else: mplImported = False + from matplotlib.patches import Patch + self.Patch = Patch from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas from matplotlib.figure import Figure graphFrame_enabled = True except ImportError: mpl = Canvas = Figure = None - enabled = False + graphFrame_enabled = False + self.legendFix = False if not graphFrame_enabled: @@ -77,7 +83,7 @@ class GraphFrame(wx.Frame): except: cache_dir = os.path.expanduser(os.path.join("~", ".matplotlib")) - cache_file = config.parsePath(cache_dir, 'fontList.cache') + cache_file = parsePath(cache_dir, 'fontList.cache') if os.access(cache_dir, os.W_OK | os.X_OK) and os.path.isfile(cache_file): # remove matplotlib font cache, see #234 @@ -91,8 +97,6 @@ class GraphFrame(wx.Frame): print("pyfa: Recommended minimum matplotlib version is 1.0.0") self.legendFix = True - self.mpl_version = mpl.__version__[0] - mplImported = True wx.Frame.__init__(self, parent, title=u"pyfa: Graph Generator", style=style, size=(520, 390)) @@ -280,7 +284,7 @@ class GraphFrame(wx.Frame): selected_color = legend_colors[i] except: selected_color = None - legend2.append(Patch(color=selected_color,label=i_name),) + legend2.append(self.Patch(color=selected_color,label=i_name),) if len(legend2) > 0: leg = self.subplot.legend(handles=legend2) diff --git a/gui/mainFrame.py b/gui/mainFrame.py index cbaa885cf..de3bffc4f 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -952,7 +952,7 @@ class MainFrame(wx.Frame): if not self.graphFrame: self.graphFrame = GraphFrame(self) - if graphFrame.enabled: + if graphFrame.graphFrame_enabled: self.graphFrame.Show() else: self.graphFrame.SetFocus()