From 972ada0697ce787de130001caa0fd2b5850ba34f Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Sat, 2 May 2020 09:41:08 +0200 Subject: [PATCH] [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 --- core/widget.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/widget.py b/core/widget.py index 2d1ad17..6b71ad2 100644 --- a/core/widget.py +++ b/core/widget.py @@ -11,6 +11,21 @@ class Widget(util.store.Store, core.input.Object): self.module = module 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): if not self.module: return 0