Usage of param Parameters in different classes

Hi,
Parameters when inherited to different class in another file does not work. I know parameters work when inherited by different class in the same file (Using Param with Panel — Panel v0.14.4), but when inherited to class in another file this does not seem to work :frowning_face:. I might be missing some basics here …?!!. Any guidance from the community would be of great help. Thanks.!!!

First File

myFirstClass.py

import param

class MyFirstClass(param.Parameterized):
           paramOne = param.String()

Second file

mySecondClass.py

import param
from myFirstClass import MyFirstClass

class MySecondClass(MyFirstClass)
             
            # paramOne here is the parameter of MyFirstClass 
            # also tried 'MyFirstClass().param.paramOne'
            @param.depends('paramOne', watch=True)  
            def foo(self):
                  print("ParamOne of myFirsClass updated...!!!")

Hi @panel_learner

You don’t explain how exactly you run your code and see that it does not work.

But for example the below works for me.

Hi @Marc .
Thank you for your reply.
Please have a look at the structure.
My starting point will be ‘myBaseClass.py’ (panel serve myBaseClass.py --autoreload --show)

myBaseClass.py

import panel as pn
import holoviews as hv
import numpy as np
from myClassOne import MyClassOne
from myClassTwo import MyClassTwo

class myClass:
    def __init__(self):
        pn.extension()
        hv.extension('bokeh')
        classOneObj = MyClassOne()
        classTwoObj = MyClassTwo()

        base = pn.template.FastListTemplate(site="Param Library",
                                            title="Learning Param",
                                            accent_base_color="#4099da",
                                            theme_toggle=False, 
                                            busy_indicator=None
                                            )
        
        base.main.extend([
            pn.Row(pn.Card(pn.Param(classOneObj.param, 
                                    show_name=False,
                                    widgets = {'name':'Parameter One', 
                                               'widget_type':pn.widgets.TextInput}),
                        title = "Card One", 
                        sizing_mode= 'stretch_width',
                        background='lightgrey'),
                    
                    pn.Card(pn.Param(classTwoObj.param.paramTwo,
                                    show_name=False,
                                    widgets = {'name':'Parameter Two',
                                               'widget_type':pn.widgets.TextInput}),
                        title = 'Card Two',
                        sizing_mode = 'stretch_width',
                        background='lightgrey') 
                )
        ])
        base.servable()

myClassObj = myClass()

myClassOne.py

import param

class MyClassOne(param.Parameterized):
    paramOne = param.String()

    @param.depends('paramOne', watch=True)
    def check(self):
        print("In MyClassOne paramOne updated...",self.paramOne)

myClassTwo.py

import param
from myClassOne import MyClassOne

class MyClassTwo(MyClassOne):
    paramTwo = param.String()

    @param.depends('paramOne', watch=True)
    def check(self):
        print("In myClassTwo, paramOne updated...",self.paramOne)