Hi @nritsche
Could you try and see if Alert._rename = {**Markdown._rename, "alert_type": None}
could solve the issue. (It’s a hack). It needs to be done before you instantiate my_alert
.
This is a bug. Please help by filing on Github.
Thanks.
Hi @nritsche
Could you try and see if Alert._rename = {**Markdown._rename, "alert_type": None}
could solve the issue. (It’s a hack). It needs to be done before you instantiate my_alert
.
This is a bug. Please help by filing on Github.
Thanks.
Thanks @marc!
Your suggestion works. I’m going to create an issue. Btw, if I change .text
nothing happens. I have to change .object
. I guess that’s a similar issue?
btw, you edited my post when you probably wanted to reply.
Thanks @nritsche. I’ve inserted the original post below
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'
So I got a working solution with
try:
my_alert.alert_type = "success"
except AttributeError:
pass
my_alert.object = "foo!"
Is there a better way?
@nritsche. The workaround should be extended to
Alert.priority=0
Alert._rename=dict(Markdown._rename, alert_type=None)
And please note the documentation is wrong. You should not use text
but object
to change the text.
I’ve created a bug report https://github.com/holoviz/panel/issues/1728 and PR with a fix https://github.com/holoviz/panel/pull/1729