There seems to be no dedicated param category so I am putting this here.
What would be the canonical way to get my instance of Test to automatically calculate b on instantiation?
Note that I prefer leaving the calculation of b outside of .view because b might be accessed from more than one function.
import param
import panel as pn
pn.extension()
class Test(param.Parameterized):
a = param.Integer(default=0, bounds=(0, 10))
@param.depends('a', watch=True)
def get_b(self):
self.b = self.a *2
@param.depends('a')
def view(self):
return pn.pane.Markdown(f'{self.a} * 2 = {self.b}')
test = Test()
test.get_b() # I would like to get rid of this line
pn.Column(test.param, test.view)