[core/widget] allow to override widget IDs

to uniquely identify a widget, allow the user to specify an ID on the
CLI

TODO: document this
This commit is contained in:
tobi-wan-kenobi 2020-05-02 09:41:08 +02:00
parent 8e71201030
commit 972ada0697

View file

@ -11,6 +11,21 @@ class Widget(util.store.Store, core.input.Object):
self.module = module self.module = module
self.name = name self.name = name
@property
def module(self):
return self.__module
@module.setter
def module(self, module):
self.__module = module
if self.index() < 0: return
if module:
custom_ids = util.format.aslist(module.parameter('id'))
if len(custom_ids) > self.index():
self.id = custom_ids[self.index()]
def index(self): def index(self):
if not self.module: return 0 if not self.module: return 0