From 32b65c9163cfecac3c18b5c8035809a7dd3d30ce Mon Sep 17 00:00:00 2001 From: Capocchi L Date: Thu, 15 Oct 2020 16:04:15 +0200 Subject: [PATCH] bug fix for py3.8 --- Complexity.py | 8 +++++--- PlotGUI.py | 33 +++++++++++++-------------------- PropertiesGridCtrl.py | 2 +- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/Complexity.py b/Complexity.py index a61be42d..1d579060 100644 --- a/Complexity.py +++ b/Complexity.py @@ -56,10 +56,12 @@ def GetMacCabeMetric(path): ### beware to use tab for devs code of models L = [getattr(cls,fct) for fct in ('extTransition','intTransition','outputFnc') if hasattr(cls, fct)] - - print(L) - source_list = list(map(inspect.getsource, L)) + ### when model is created, the transition functions are empty... + try: + source_list = list(map(inspect.getsource, L)) + except Exception as info: + source_list = [] L_args = [] diff --git a/PlotGUI.py b/PlotGUI.py index 9859b835..81f6bf48 100644 --- a/PlotGUI.py +++ b/PlotGUI.py @@ -100,12 +100,11 @@ def __init__(self, parent=None, id=wx.NewIdRef(), title="Time Plotting"): self.normalize = False self.home = HOME_PATH -# self.sldh = wx.Slider(self, wx.NewIdRef(), 10, 0, 50, (-1, -1), (250, -1), wx.SL_AUTOTICKS | wx.SL_HORIZONTAL | wx.SL_LABELS) -# self.sldv = wx.Slider(self, wx.NewIdRef(), 10, 0, 50, (-1, -1), (50, 150), wx.SL_AUTOTICKS | wx.SL_VERTICAL | wx.SL_LABELS) - self.client = plot.PlotCanvas(self) - #self.client.pointLabelFunc(self.drawPointLabel) + self.InitUI() + + def InitUI(self): ##Now Create the menu bar and items self.mainmenu = wx.MenuBar() @@ -186,34 +185,30 @@ def __init__(self, parent=None, id=wx.NewIdRef(), title="Time Plotting"): self.Bind(wx.EVT_MENU,self.OnScrUp, scrUp) self.Bind(wx.EVT_MENU,self.OnScrRt, scrRt) self.Bind(wx.EVT_MENU,self.OnReset, reset) - + + self.client.canvas.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown) + self.client.canvas.Bind(wx.EVT_MOTION, self.OnMotion) + self.Bind(wx.EVT_CLOSE, self.OnQuit) + ### A status bar to tell people what's happening self.CreateStatusBar(1) ### create tool bar - self.tb = self.BuildToolbar() + self.BuildToolbar() vbox = wx.BoxSizer(wx.VERTICAL) - hbox = wx.BoxSizer(wx.HORIZONTAL) - - hbox.Add(self.client, 1, wx.ALIGN_CENTRE) - - vbox.Add(self.tb, 0, wx.EXPAND) - vbox.Add(hbox, 1, wx.ALIGN_CENTRE) + + vbox.Add(self.client, 1, wx.EXPAND) self.SetSizer(vbox) - - self.client.canvas.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown) - self.client.canvas.Bind(wx.EVT_MOTION, self.OnMotion) - - self.Bind(wx.EVT_CLOSE, self.OnQuit) self.Layout() def BuildToolbar(self): """ Create ToolBar """ - tb = wx.ToolBar(self, style=wx.TB_HORIZONTAL|wx.NO_BORDER|wx.TB_FLAT) + tb = self.CreateToolBar() + #tb = wx.ToolBar(self, style=wx.TB_HORIZONTAL|wx.NO_BORDER|wx.TB_FLAT) tb.SetToolBitmapSize((16,16)) zoomLabel, zoomId = self.enableZoom.GetItemLabelText(), self.enableZoom.GetId() @@ -243,8 +238,6 @@ def BuildToolbar(self): tb.Realize() - return tb - def OnMove(self, event): event.Skip() diff --git a/PropertiesGridCtrl.py b/PropertiesGridCtrl.py index d4f95671..76cc5984 100644 --- a/PropertiesGridCtrl.py +++ b/PropertiesGridCtrl.py @@ -576,7 +576,7 @@ def GetValue(self, row, col): try: return self.data[row][col][0] if isinstance(self.data[row][col], tuple) else self.data[row][col] - except IndexError: + except Exception as e: return None def SetValue(self, row, col, value):