fix oops
This commit is contained in:
@@ -52,20 +52,26 @@ class GraphFrame(wx.Frame):
|
|||||||
global graphFrame_enabled
|
global graphFrame_enabled
|
||||||
global mplImported
|
global mplImported
|
||||||
|
|
||||||
|
self.Patch = None
|
||||||
|
self.mpl_version = -1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import matplotlib as mpl
|
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')
|
mpl.use('wxagg')
|
||||||
mplImported = True
|
mplImported = True
|
||||||
from matplotlib.patches import Patch
|
|
||||||
else:
|
else:
|
||||||
mplImported = False
|
mplImported = False
|
||||||
|
from matplotlib.patches import Patch
|
||||||
|
self.Patch = Patch
|
||||||
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas
|
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas
|
||||||
from matplotlib.figure import Figure
|
from matplotlib.figure import Figure
|
||||||
graphFrame_enabled = True
|
graphFrame_enabled = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
mpl = Canvas = Figure = None
|
mpl = Canvas = Figure = None
|
||||||
enabled = False
|
graphFrame_enabled = False
|
||||||
|
|
||||||
|
|
||||||
self.legendFix = False
|
self.legendFix = False
|
||||||
if not graphFrame_enabled:
|
if not graphFrame_enabled:
|
||||||
@@ -77,7 +83,7 @@ class GraphFrame(wx.Frame):
|
|||||||
except:
|
except:
|
||||||
cache_dir = os.path.expanduser(os.path.join("~", ".matplotlib"))
|
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):
|
if os.access(cache_dir, os.W_OK | os.X_OK) and os.path.isfile(cache_file):
|
||||||
# remove matplotlib font cache, see #234
|
# remove matplotlib font cache, see #234
|
||||||
@@ -91,8 +97,6 @@ class GraphFrame(wx.Frame):
|
|||||||
print("pyfa: Recommended minimum matplotlib version is 1.0.0")
|
print("pyfa: Recommended minimum matplotlib version is 1.0.0")
|
||||||
self.legendFix = True
|
self.legendFix = True
|
||||||
|
|
||||||
self.mpl_version = mpl.__version__[0]
|
|
||||||
|
|
||||||
mplImported = True
|
mplImported = True
|
||||||
|
|
||||||
wx.Frame.__init__(self, parent, title=u"pyfa: Graph Generator", style=style, size=(520, 390))
|
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]
|
selected_color = legend_colors[i]
|
||||||
except:
|
except:
|
||||||
selected_color = None
|
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:
|
if len(legend2) > 0:
|
||||||
leg = self.subplot.legend(handles=legend2)
|
leg = self.subplot.legend(handles=legend2)
|
||||||
|
|||||||
@@ -952,7 +952,7 @@ class MainFrame(wx.Frame):
|
|||||||
if not self.graphFrame:
|
if not self.graphFrame:
|
||||||
self.graphFrame = GraphFrame(self)
|
self.graphFrame = GraphFrame(self)
|
||||||
|
|
||||||
if graphFrame.enabled:
|
if graphFrame.graphFrame_enabled:
|
||||||
self.graphFrame.Show()
|
self.graphFrame.Show()
|
||||||
else:
|
else:
|
||||||
self.graphFrame.SetFocus()
|
self.graphFrame.SetFocus()
|
||||||
|
|||||||
Reference in New Issue
Block a user