-
-
Notifications
You must be signed in to change notification settings - Fork 571
Closed
Milestone
Description
After creating an alert with
my_alert = pn.pane.Alert("foo", alert_type="primary")
I want to change it’s properties later. I tried
my_alert.alert_type = "success"
my_alert.object = "foo!"
, which works, but gives me a
File "/home/rick/bondia/bondia/gui.py", line 209, in _click_opinion
my_alert.alert_type = "success"
File "/home/rick/.local/lib/python3.8/site-packages/param/parameterized.py", line 302, in _f
instance_param.__set__(obj, val)
File "/home/rick/.local/lib/python3.8/site-packages/param/parameterized.py", line 304, in _f
return f(self, obj, val)
File "/home/rick/.local/lib/python3.8/site-packages/param/parameterized.py", line 915, in __set__
obj.param._call_watcher(watcher, event)
File "/home/rick/.local/lib/python3.8/site-packages/param/parameterized.py", line 1554, in _call_watcher
watcher.fn(event)
File "/home/rick/.local/lib/python3.8/site-packages/panel/reactive.py", line 175, in _param_change
self._update_model(events, msg, root, model, doc, comm)
File "/home/rick/.local/lib/python3.8/site-packages/panel/reactive.py", line 132, in _update_model
self._changing[root.ref['id']] = [
File "/home/rick/.local/lib/python3.8/site-packages/panel/reactive.py", line 134, in <listcomp>
if not model.lookup(attr).property.matches(getattr(model, attr), value)
File "/home/rick/.local/lib/python3.8/site-packages/bokeh/core/has_props.py", line 417, in lookup
return getattr(cls, name)
AttributeError: type object 'HTML' has no attribute 'alert_type'
As suggested by @MarcSkovMadsen, adding this before instantiation of the alert solves the issue (see https://discourse.holoviz.org/t/how-to-change-alert-properties-after-creation/1369/2):
Alert._rename = {**Markdown._rename, "alert_type": None}
It should probably also be possible to change the alert text with my_alert.text = "bar", but one has to do my_alert.object = "bar" to archieve this.
software version info
Ubuntu 20.04.1 LTS
Python 3.8.5
panel 0.10.1
Metadata
Metadata
Assignees
Labels
No labels