The current code to update the custom data is written along with the routine updating the widget c, since they have the same parent dependencies. However, with more intermediate variables, it’ll become unwieldy.
I want to create a custom class instead of a dictionary that can update itself with whenever widgets a or b change but can’t quite figure out how to specify widgets as dependencies, since they are not regular parameters. Is there a way to do this without writing the entire GUI as a subclass of param.Parameterized?
Though I’d like to be able to use this as a dependency for downstream panes/widgets, so changes to this custom datatype trigger updates on them. The desired sequence of update events is:
widget a/b -> data -> widget c -> plot1/plot2.
With the current form, both DataHolder and the widget c receive updates on a change to either widget a or widget b, and the order in which they get updated isn’t guaranteed.
Thank you Marc for the exhaustive answer! Since installing Panel yesterday, snippets posted by you on the forum have helped me a lot.
When serving the dashboard as an application, it clearly makes sense to put the GUI in a single param.Parameterized class, since everything is specified cleanly. Though for working in a jupyter notebook, it seems a bit inconvenient if I only want to add widgets around 3/4 parameters. Working with widgets feels natural in that changes needed are:
replace variables in my imperative code with widget.value.
add a panel.depends decorator around the methods that should be updated.
A panel/param construct that can wrap an arbitrary python variable and also have other widgets/params as parent/child dependencies, would probably be helpful here. I’ll look into subclassing one of the exposed base classes in the param library. Have you come across a similar use case?
I came up with this but it seems to either throw a javascript error or run the update method multiple times for a single change, so I’ll go with creating the big Parameterized class. Thanks @Marc.
No, that didn’t work. I think the pn.depends decorator needs widgets to be passed in, so inheriting from a panel Widget seems necessary.
My hunch is a widget also needs some corresponding javascript code (the web console had an error citing an unregistered class), so just subclassing in python didn’t work.
I apologize since you have already given a working example, could you please point me to any examples where the GUI is split between >1 param.Parameterized classes, and how to make them depend on one other.