Hi,
I’ve just recently started using Panel and I’m having a problem with FloatPanel Behavior.
The MWE is the following:
import panel as pn
import param
from panel.widgets.base import WidgetBase
from panel.custom import PyComponent
class TestPanel(WidgetBase, PyComponent):
str = param.String("An error occured")
width = param.Integer(400)
def __init__(self, **params):
if not "visible" in params:
params["visible"] = False
super().__init__(**params)
self.closebutton = pn.widgets.Button(name="Close")
self.panel = pn.FloatPanel(pn.pane.Markdown(self.param['str']), self.closebutton, config = {"headerControls": {"close": "remove", "maximize": "remove"}},
width=self.width, position="center",
# contained=True,
contained=False,
# contained=self.param["visible"].rx.pipe(lambda x: not x)
)
pn.bind(lambda c: setattr(self, "visible", False), self.closebutton, watch=True)
def __panel__(self):
return self.panel
tp = TestPanel()
showbutton = pn.widgets.Button(name="ShowFloatPanel")
pn.bind(lambda c: setattr(tp, "visible", True), showbutton, watch=True)
pn.Row(showbutton, tp).servable()
With contained=True, everything seems to work as expected. However I would like the floating window to be movable. With contained=False, it seems I can not toggle visibility (i.e. the float window is always visible). With contained = not visible, I get an exception about some object with an id already existing…
Can anyone recreate these issues ?
Is this a bug ?
Should I be coding this this way ?