added a workaround for overlapping widgets

This commit is contained in:
2021-06-08 12:10:16 +02:00
parent f1737aa59f
commit 6d29853010

View File

@ -30,13 +30,15 @@ class Frame(Column):
self.btn_cfg.on_click(self.do_click_cfg)
self.dummy = dummy = Div(width=0, height=0)
# wrap fig and cfg such that their container can be hidden during the visibility switch
# wrap with another container to maintain size
# combined gives a relatively smooth (albeit slow) transition between the two states
self.inner = inner = Row(plt, cfg)
size_maintainer = Row(inner, min_width=plt.width, min_height=plt.height) #TODO: why min_* ?
super().__init__(header, size_maintainer, Spacer(height=35), name=name)
super().__init__(header, size_maintainer, Spacer(height=35), dummy, name=name)
def on_click_close(self, handler):
@ -47,11 +49,12 @@ class Frame(Column):
self.btn_close.on_click(wrapper)
def do_click_cfg(self):
toggle_button_state(self.btn_close) # do not close plot from cfg dialog
toggle_button_type(self.btn_cfg, "default", "warning")
toggle_button_state(self.btn_close) # do not close plot from cfg dialog
self.inner.visible = False
switch_visibility(self.plt, self.cfg)
self.inner.visible = True
toggle_visibility(self.dummy) # workaround for overlapping widgets
@ -64,5 +67,8 @@ def toggle_button_type(btn, type1, type2):
def switch_visibility(a, b):
a.visible, b.visible = b.visible, a.visible
def toggle_visibility(a):
a.visible = not a.visible