def test_gridspec_stretch_with_slice_setitem(document, comm): div1 = Div() div2 = Div() gspec = GridSpec(sizing_mode='stretch_both') gspec[0, 0:2] = div1 gspec[1, 2] = div2 model = gspec.get_root(document, comm=comm) assert model.children == [(div1, 0, 0, 1, 2), (div2, 1, 2, 1, 1)] assert div1.sizing_mode == 'stretch_both' assert div2.sizing_mode == 'stretch_both'
def test_gridspec_fixed_with_upper_partial_slice_setitem(document, comm): div1 = Div() div2 = Div() gspec = GridSpec(width=900, height=500) gspec[0, :2] = div1 gspec[1, 2] = div2 model = gspec.get_root(document, comm=comm) assert model.children == [(div1, 0, 0, 1, 2), (div2, 1, 2, 1, 1)] assert div1.width == 600 assert div1.height == 250 assert div2.width == 300 assert div2.height == 250
def test_gridspec_fixed_with_int_setitem(document, comm): div1 = Div() div2 = Div() gspec = GridSpec(width=800, height=500) gspec[0, 0] = div1 gspec[1, 1] = div2 model = gspec.get_root(document, comm=comm) assert model.children == [(div1, 0, 0, 1, 1), (div2, 1, 1, 1, 1)] assert div1.width == 400 assert div1.height == 250 assert div2.width == 400 assert div2.height == 250
def test_gridspec_cleanup(document, comm): spacer = Spacer() gspec = GridSpec() gspec[0, 0] = spacer model = gspec.get_root(document, comm) ref = model.ref['id'] assert ref in gspec._models assert ref in spacer._models gspec._cleanup(model) assert ref not in gspec._models assert ref not in spacer._models
def test_gridspec_stretch_with_int_setitem(document, comm): div1 = Div() div2 = Div() gspec = GridSpec(sizing_mode='stretch_both') gspec[0, 0] = div1 gspec[1, 1] = div2 model = gspec.get_root(document, comm=comm) assert model.children == [(div1, 0, 0, 1, 1), (div2, 1, 1, 1, 1)] assert div1.sizing_mode == 'stretch_both' assert div1.style == {'width': '100%', 'height': '100%'} assert div2.sizing_mode == 'stretch_both' assert div2.style == {'width': '100%', 'height': '100%'}
def test_gridspec_stretch_with_replacement_pane(document, comm): slider = IntSlider(start=0, end=2) @depends(slider) def div(value): return Div(text=str(value)) gspec = GridSpec(sizing_mode='stretch_width') gspec[0, 0:2] = Div() gspec[1, 2] = div model = gspec.get_root(document, comm=comm) ((div1, _, _, _, _), (row, _, _, _, _)) = model.children div2 = row.children[0] assert div1.sizing_mode == 'stretch_width' assert div1.height == 300 assert div2.sizing_mode == 'stretch_width' assert div2.height == 300 slider.value = 1 assert row.children[0] is not div2 assert row.children[0].sizing_mode == 'stretch_width' assert row.children[0].height == 300