Hello,
I am looking for a way to declare a custom widget with param.Parameterized and then leverage the full decorator capabilities in the classes that instantiate my widget. Something like this:
class MyWidget(param.Parameterized):
button = pn.widgets.Button(name="some button")
some_value = 1
@param.depends('button.value')
def update_value(self):
self.value += 1
def view(self):
return pn.Row(self.button)
Then use the widget in other classes/apps in the same way as built in widgets by leveraging decorators. Something like this:
class BigApp(param.Parameterized):
custom_widget = MyWidget()
@param.depends('custom_widget.value`, watch=True)
def print_value(self):
print("value has changed in the custom widget")
def view(self):
return pn.Row(self.custom_widget.view())
A design that does accomplish this to a certain extent is by passing the callable from the parent class to the custom widget class, but decorator would be much nicer IMO.
Does any of the panel gurus know how to accomplish this?
Many thanks!
Ogi