panel icon indicating copy to clipboard operation
panel copied to clipboard

pn.Flexbox does not accept and display a.param list of widgets, but Pn.Row / Pn.Column layout do.

Open Coderambling opened this issue 1 year ago • 0 comments

ALL software version info

Panel

Description of expected behavior and the observed behavior

When I do pn.Row(objects=widget_list.param.value), widgets are shown, added / removed when widget_list changes. But when I do pn.Flexbox(objects=widget_list.param.value), I get error:

TypeError: panel.reactive.ReactiveHTML.init() got multiple values for keyword argument 'objects'

pn.Flexbox(widget_list.param.value)does not display the widgets, but instead a ListInput Widget that contains the text of widget_list.value. pn.Row also does this by the way).

The .param list object "resolves" sucesfully to a list of widgets when used with pn.Row / pn. Column, but not with Flexbox.

Complete, minimal, self-contained example code that reproduces the issue

Expected behavior.

Code example of expected behavor, using Row

import panel as pn
pn.extension(theme='dark')
w1 = pn.widgets.Button(name='Click me 01') # , icon='caret-right', button_type='primary')
w2 = pn.widgets.Button(name='Click me 02')
all_dicts03 = {
    'Button01': w1,
    'Button02': w2
}
widgets_selector01 = pn.widgets.CrossSelector(options=all_dicts03)

# widget_row01=pn.Row(widgets_selector01.param.value) # shows a field
# with title:Value and text content:[Button(name='Click me 01'), Button(name='Click me 02')]
widget_row01=pn.Row(objects=widgets_selector01.param.value) # Adding objects=, however, makes it work.

Flexbox04 = pn.FlexBox(widgets_selector01, widget_row) # works in next cell, buttons show / disappear when using selector boxes.

# Next notebook cell: Flexbox04. Execute cell and it works as expected.

# param value: Type:List
# Value:<param.parameters.List object at 0x78e2e9a40a90>

Observed behavior (with Flexbox)


# Next notebook cells: 
Flexbox05 = pn.FlexBox(*widgets_selector01.value) # works. without .param, buttons are shown

Flexbox06 = pn.FlexBox(widgets_selector01.param.value) # Should show the 2 buttons, but instead shows a field
# with title:Value and text content:[Button(name='Click me 01'), Button(name='Click me 02')]

#This is the same behavior as when doing pn.Row(widgets_selector01.param.value)
# This content is identical to the value of widget_selector01.value.

Flexbox08 = pn.FlexBox(objects=widgets_selector01.param.value)
# TypeError: panel.reactive.ReactiveHTML.__init__() got multiple values for keyword argument 'objects'

Flexbox09 = pn.FlexBox(*widgets_selector01.param.value)
# TypeError: panel.layout.flex.FlexBox() argument after * must be an iterable, not List


Stack traceback and/or browser JavaScript console output

Screenshots or screencasts of the bug in action

  • [ ] I may be interested in making a pull request to address this

Coderambling avatar Feb 24 '24 21:02 Coderambling