Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Names of Parameterized options not used as labels of Selectors #3688

Closed
MarcSkovMadsen opened this issue Jul 12, 2022 · 12 comments · Fixed by #3755
Closed

Regression: Names of Parameterized options not used as labels of Selectors #3688

MarcSkovMadsen opened this issue Jul 12, 2022 · 12 comments · Fixed by #3755

Comments

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Jul 12, 2022

Panel 0.13.1

import panel as pn

component1=pn.panel("Value1")
component2=pn.panel("Value2")

selection = pn.widgets.RadioBoxGroup(value=component1, options=[component1, component2])

pn.Column(
    selection
).servable()

shows

image

I would expect "Value1" and "Value2" to be shown as labels. It used to be like that and it was simple and powerful.

@maximlt
Copy link
Member

maximlt commented Jul 19, 2022

Even if it worked before, I'm not sure it should actually have, as I find this usage as shown in the example pretty confusing. Do you have a more specific use case in mind that would motivate supporting that?

@philippjfr
Copy link
Member

I can't think of any mechanism that would have allowed this to work in the past tbh. I'm -0 on supporting this, I think it's not unreasonable to support but it seems of very limited utility. The .object of a pane is very rarely something that would make sense as an option label (e.g. what happens for non-string types and what happens if the string is very long). It does seem better to be explicit about the actual label.

@philippjfr philippjfr added wontfix This will not be worked on and removed type: bug labels Jul 20, 2022
@philippjfr
Copy link
Member

philippjfr commented Jul 20, 2022

Also just tested all Panel versions in the 0.11.x, 0.12.x series as well as 0.13.0 and this has never worked as far as I can tell. Therefore I'm going to close as invalid.

@philippjfr
Copy link
Member

The reason why I also think this is wrong is that the .object of a pane is mutable. If you update it and the label does not also update it is very confusing.

@jbednar
Copy link
Member

jbednar commented Jul 21, 2022

Was this maybe the intent of the original post?

import panel as pn
pn.extension()

component1=pn.panel("Value1", name="V1")
component2=pn.panel("Value2", name="V2")

selection = pn.widgets.RadioBoxGroup(value=component1, options=[component1, component2])

pn.Column(
    selection
).servable()

In that case I would have expected name to be used as the option label, but it isn't:

image

@maximlt
Copy link
Member

maximlt commented Jul 22, 2022

I don't know if using name= is something we want to promote. name= is used as the label for many widgets and there's been discussion (e.g. #2834) to migrate to title=.

@jbednar
Copy link
Member

jbednar commented Jul 22, 2022

Sure, but it's worth checking if it used to work this way...

@MarcSkovMadsen
Copy link
Collaborator Author

MarcSkovMadsen commented Jul 22, 2022

I've checked panel==0.10.0/ param==1.9.3 with this example

import param
import panel as pn

class MyClass(param.Parameterized):
    value = param.Number()

options = [
    MyClass(name="obj1"), MyClass(name="obj2")
]

pn.widgets.Select(options=options).servable()

It does not work.

I simply don't understand it. In my head I've used that so many times :-)

I would still argue it is very valuable to support and very much in line with how the Parameter Subobjects example works for parameterized classes and how Tabs works. I would very much appreciate you reconsider @philippjfr. It would make using widgets to select between parameterized objects/ subcomponents much easier that having to construct a dictionary and hand that around together with the objects.

Parameter Subobjects

import param
import panel as pn


options = [pn.panel("Value1", name="value1"), pn.panel("Value2", name="value2")]

class MyOptionsClass(param.Parameterized):
    value = param.Selector(objects=options)

my_options = MyOptionsClass()

pn.Param(my_options, widgets={"value": pn.widgets.RadioBoxGroup}, expand_button=False).servable()

image

Tabs

import panel as pn

options = [pn.panel("Value1", name="value1"), pn.panel("Value2", name="value2")]

pn.Tabs(*options).servable()

image

@philippjfr
Copy link
Member

Wait, that example is very different from the example you had posted originally. I fully agree that the name parameter should be used.

@MarcSkovMadsen
Copy link
Collaborator Author

MarcSkovMadsen commented Jul 22, 2022

I'm using the other examples because I believe they are all should behave similar using the name parameter.

I guess I thought the widgets would use the name parameter by default because I've been using the param.Selector and pn.Param so much. I thought it was the widget that used the name parameter by default. But it seems Param does the magic.

@MarcSkovMadsen
Copy link
Collaborator Author

MarcSkovMadsen commented Jul 22, 2022

Ahh. I forgot the

Was this maybe the intent of the original post?

import panel as pn
pn.extension()

component1=pn.panel("Value1", name="V1")
component2=pn.panel("Value2", name="V2")

selection = pn.widgets.RadioBoxGroup(value=component1, options=[component1, component2])

pn.Column(
    selection
).servable()

In that case I would have expected name to be used as the option label, but it isn't:

image

Yes. This was the initial example I would like to display the value of the name parameter. But it looks like

image

@philippjfr philippjfr reopened this Jul 22, 2022
@jbednar
Copy link
Member

jbednar commented Jul 22, 2022

Ah, ok. You confused us all with an apparently actual issue with an accurate issue title but the wrong code snippet. :-) I too think it used to say V1 where it now says Markdown(str, name='V1'), and V1 seems much more appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants