Skip to content

Instantly share code, notes, and snippets.

@LinuxIsCool
Forked from bhargavkakadiya/example.py
Created March 16, 2023 22:14
Show Gist options
  • Save LinuxIsCool/3229e9d7a756eae46c7033d10bf3bc3f to your computer and use it in GitHub Desktop.
Save LinuxIsCool/3229e9d7a756eae46c7033d10bf3bc3f to your computer and use it in GitHub Desktop.
Simple example for Param Panel class interactions
## Run it on jupyter notebook for interactive panel
import param as pm
import panel as pn
class A(pm.Parameterized):
a = pm.Number(2)
class B(pm.Parameterized):
def __init__(self, a:A, **params):
super().__init__(**params)
self.a = a
b = pm.Number(2)
@pm.depends('a.a', 'b')
def sum(self):
return self.a.a + self.b
a = A()
b = B(a)
pn.Column(a, b, b.sum)
## Result
## changing parameter a and b should reflect change in sum
@LinuxIsCool
Copy link
Author

Good base case to remember.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment