holoviz-topics / EarthSim

Tools for working with and visualizing environmental simulations.
https://earthsim.holoviz.org
BSD 3-Clause "New" or "Revised" License
65 stars 21 forks source link

Combine parambokeh widgets from different Parameterized objects #180

Closed kcpevey closed 5 years ago

kcpevey commented 6 years ago

I have two sets (classes) of parambokeh widgets. They currently visualize like this:
param1

I have 3 questions/comments/requests:

  1. Is there a way to remove the param class name from the top of the list? (e.g. "input_param09535")
  2. Why is it that when I move my param class to an external file instead of in the notebook, it generates a random number at the end of the param class name (e.g. "09535")?
  3. Is it possible to remove any spacing between the two visualized parambokeh widget classes? I like to be able to have separate classes visualize seamlessly (for reusing codebase).

To summarize, what I'd like to see is this:
param2

Is that possible now or how much effort would that require?

jbednar commented 6 years ago

When you use Widgets with a class, the default name is the name of the class. When you use it with an instance, it shows the default name of the instance, which has the numbers to distinguish it from other instances of the same class. You can omit the names entirely:

image

kcpevey commented 6 years ago

Thanks. That answers the first questions 1 and 2. Question 3 was how can I remove the extra padding between consecutive widgets. Applying what you've mentioned here, I now have the following image which looks good with the exception of the gap between the two widget sets (yellow line). Is there any way to make that seamless so that I can't tell that I have two widget sets (i.e. it just appears to be one set)?

param3

jbednar commented 6 years ago

I imagine we could get rid of that space, but offhand I don't know what's generating it.

sdc50 commented 6 years ago

If you want all of the widgets to appear as one block then would it make sense to create a class that inherits from the other two classes so that it contains all of the widgets?

image

jbednar commented 6 years ago

That would certainly work, but it depends what those widgets are controlling whether that's appropriate. Using multiple inheritance just to eliminate whitespace shouldn't be necessary, so if you tell us that the bit of whitespace is a serious issue, we can certainly investigate and remove it; shouldn't be a big deal.

But I'll rename this issue to be about a more general solution for this problem, namely that I think we need to make it simpler to pick and choose some parameters from a variety of objects and show them all as a single grouping. It should be just a default that paramnb.Widgets dumps out all parameters from one object; instead people are very likely to need to configure multiple different objects to achieve what they want, and it should be simple to group those into a single block of widgets for display. That's a bit bigger job than just eliminating a bit of whitespace, but it should also make lots of things people want to do simpler, so I think it's important to do.

jlstevens commented 6 years ago

I think we need to make it simpler to pick and choose some parameters from a variety of objects and show them all as a single grouping.

I agree. This would make parts of the dashboard code simpler and it would probably also help me lay things out more nicely too.

kcpevey commented 6 years ago

@jbednar I agree.

@sdc50 I have a use case where the two classes are not actually related, I just want to visualize the two classes at the same time. The above example isn't a great example of that.

kcpevey commented 5 years ago

The same whitespace in between classes is also visible in panel objects @philippjfr

jbednar commented 5 years ago

Could be related to https://github.com/pyviz/panel/issues/93

philippjfr commented 5 years ago

Is there a way to remove the param class name from the top of the list? (e.g. "input_param09535")

Yes, the Param pane now has a show_name parameter.

Why is it that when I move my param class to an external file instead of in the notebook, it generates a random number at the end of the param class name (e.g. "09535")?

The numbers are now stripped.

Is it possible to remove any spacing between the two visualized parambokeh widget classes? I like to be able to have separate classes visualize seamlessly (for reusing codebase).

Yes, you can now do something like this:

class A(param.Parameterized):

    a = param.Number(default=1)

class B(param.Parameterized):

    b = param.Number(default=1)

p1 = pn.panel(A, show_name=False)
p2 = pn.panel(B, show_name=False)

pn.layout.WidgetBox(p1[0], p2[0])

This will merge the tools into a single WidgetBox without any gap.