[engine] Add override for widget IDs
Add a generic "<module>.id" parameter that allows a user to override the auto-generated IDs for a widget - the parameter is a list of IDs that will replace each widget's ID in turn. see #547
This commit is contained in:
parent
bff7788514
commit
8ae8fbb989
1 changed files with 4 additions and 0 deletions
|
@ -295,8 +295,12 @@ class Engine(object):
|
||||||
self._current_module = module
|
self._current_module = module
|
||||||
module.update_wrapper(module.widgets())
|
module.update_wrapper(module.widgets())
|
||||||
if module.error is None:
|
if module.error is None:
|
||||||
|
widget_ids = module.parameter('id', '').split(',')
|
||||||
|
idx = 0
|
||||||
for widget in module.widgets():
|
for widget in module.widgets():
|
||||||
widget.link_module(module)
|
widget.link_module(module)
|
||||||
|
widget.id = widget_ids[idx] if idx < len(widget_ids) else widget.id
|
||||||
|
idx = idx + 1
|
||||||
self._output.draw(widget=widget, module=module, engine=self)
|
self._output.draw(widget=widget, module=module, engine=self)
|
||||||
else:
|
else:
|
||||||
self._output.draw(widget=module.errorWidget(), module=module, engine=self)
|
self._output.draw(widget=module.errorWidget(), module=module, engine=self)
|
||||||
|
|
Loading…
Reference in a new issue