diff --git a/src/dynamic_graph/entity.py b/src/dynamic_graph/entity.py index 7c488807a7e0dff6d8bc7e6a85bf6b1f2c4b1bba..d1d18293bf06362cc857efd2dca4ed73d1fd131c 100644 --- a/src/dynamic_graph/entity.py +++ b/src/dynamic_graph/entity.py @@ -3,7 +3,7 @@ Author: Florent Lamiraux """ -import wrap, signal_base +import wrap, signal_base, new entityClassNameList = [] if 'display' not in globals().keys(): @@ -132,6 +132,16 @@ class Entity (object) : except: object.__getattr__(self, name) + def boundNewCommand(self,cmdName): + """ + At construction, all existing commands are bound directly in the class. + This method enables to bound new commands dynamically. These new bounds + are not made with the class, but directly with the object instance. + """ + docstring = wrap.entity_get_command_docstring(self.obj, cmdName) + cmd = commandMethod(cmdName,docstring) + setattr(self,cmdName,new.instancemethod( cmd, self,self.__class__)) + # Script short-cuts: don't use this syntaxt in python coding, # use it for debuging online only! @property