diff --git a/Menu.py b/Menu.py index 4ed70c4d..a3fd1188 100644 --- a/Menu.py +++ b/Menu.py @@ -993,7 +993,6 @@ def __init__(self, shape, event): self.__canvas.Bind(wx.EVT_MENU, self.__canvas.OnLock, id=ID_LOCK_SHAPE) self.__canvas.Bind(wx.EVT_MENU, self.__canvas.OnUnLock, id=ID_UNLOCK_SHAPE) - elif isinstance(shape, Container.ResizeableNode): Delete_menu = AppendItem(delete) @@ -1013,7 +1012,7 @@ def __init__(self, shape, event): else: Edit_menu = AppendItem(edit) - if shape.isPYC(): + if isinstance(shape, Container.CodeBlock) and shape.isPYC(): Edit_menu.Enable(False) Log_menu = AppendItem(log) diff --git a/Mixins/Attributable.py b/Mixins/Attributable.py index 77461145..529ec760 100644 --- a/Mixins/Attributable.py +++ b/Mixins/Attributable.py @@ -22,7 +22,7 @@ #--------------------------------------------------------- class Attributable: - """ AttributeEditor mixin class to edit shape properties. + """ AttributeEditor mixin class to edit shape properties """ ### Static variable for default graphical properties display @@ -44,7 +44,7 @@ def __init__(self): ### def AddAttribute(self, name, typ=""): - """ Add attribute if not exist. + """ Add attribute if not exist """ if not hasattr(self, name): @@ -54,28 +54,34 @@ def AddAttribute(self, name, typ=""): ### def GetAttributes(self): - """ Return attributes attribute. + """ Return attributes attribute """ return self.attributes ### def SetAttributes(self, L): - """ Set attributes list. + """ Set attributes list """ assert(isinstance(L,list)) + ### set attribute + for name in L: + if not hasattr(self, name): + setattr(self, name, '') + ### set attributes list - self.attributes = [setattr(self, name, '') for name in L if not hasattr(self, name)] + self.attributes = L ### def AddAttributes(self, attrs): - """ Extend attributes list. + """ Extend attributes list """ - self.attributes.extend([a for a in attrs if a not in self.attributes]) + for attr in [a for a in attrs if a not in self.attributes]: + self.attributes.append(attr) ### def RemoveAttribute(self, name): - """ Remove attribute name. + """ Remove attribute name """ ### delete the attribute if hasattr(self,name): diff --git a/Mixins/Savable.py b/Mixins/Savable.py index d462dde9..c1f98214 100644 --- a/Mixins/Savable.py +++ b/Mixins/Savable.py @@ -272,15 +272,15 @@ def Load(self, obj_loaded, fileName = None): ### Check comparison between serialized attribut (L) and normal attribut (dump_attributes) ### for model build with a version of devsimpy <= 2.5 ### font checking - # if len(obj_loaded.dump_attributes) != len(L): - # if fileName.endswith(DumpZipFile.ext[-1]): - # if not isinstance(L[9], list): - # import wx - # L.insert(9, [FONT_SIZE, 74, 93, 700, 'Arial']) - # else: - # if not isinstance(L[6], list): - # import wx - # L.insert(6, [FONT_SIZE, 74, 93, 700, 'Arial']) + if len(obj_loaded.dump_attributes) != len(L): + if fileName.endswith(DumpZipFile.ext[-1]): + if not isinstance(L[9], list): + import wx + L.insert(9, [FONT_SIZE, 74, 93, 700, 'Arial']) + else: + if not isinstance(L[6], list): + import wx + L.insert(6, [FONT_SIZE, 74, 93, 700, 'Arial']) #======================================================================= diff --git a/ZipManager.py b/ZipManager.py index 2556a112..5d773a29 100644 --- a/ZipManager.py +++ b/ZipManager.py @@ -382,7 +382,7 @@ def GetModule(self, rcp: bool=False)->types.ModuleType: try: ### module is referenced in sys.modules with the format: ### the last tag allow to differenciate the model with the same name but different extention in the same lib. - fullname = "".join([os.path.basename(os.path.dirname(self.fn)), py_fn.split('.py')[0],self.fn.split('.')[-1]]) + fullname = "".join([os.path.basename(os.path.dirname(self.fn)), py_fn.split('.py')[0], self.fn.split('.')[-1]]) return self.ImportModule() if fullname not in sys.modules else sys.modules[fullname] ### model has not python file ! except Exception as e: @@ -428,7 +428,7 @@ def ImportModule(self)->types.ModuleType: ### Now import of .amd or .cmd module is composed by DomainModel (no point!). ### Example : import CollectorMessageCollectoramd or CollectorMessageCollectorcmd - fullname = "".join([os.path.basename(os.path.dirname(self.fn)), getPythonModelFileName(self.fn).split('.py')[0],self.fn.split('.')[-1]]) + fullname = "".join([os.path.basename(os.path.dirname(self.fn)), getPythonModelFileName(self.fn).split('.py')[0], self.fn.split('.')[-1]]) sys.modules[fullname] = module return module @@ -444,7 +444,7 @@ def ReImport(self): try: ### reload submodule from module dependencies! - fullname = "".join([os.path.basename(os.path.dirname(self.fn)), getPythonModelFileName(self.fn).split('.py')[0]]) + fullname = "".join([os.path.basename(os.path.dirname(self.fn)), getPythonModelFileName(self.fn).split('.py')[0], self.fn.split('.')[-1]]) module = sys.modules[fullname] domain_name = os.path.basename(os.path.dirname(self.fn)) for name in dir(module):