Created
November 30, 2022 22:31
-
-
Save LinuxIsCool/8d8e85f672aca23c3a0e0affda65ca67 to your computer and use it in GitHub Desktop.
Minimum viable embedded app and dynamic display threshold example for python param panel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import param as pm | |
| import panel as pn | |
| pn.extension() | |
| class Protocol(pm.Parameterized): | |
| display_level = pm.Integer(default=1, bounds=(0, 2), step=1, precedence=2) | |
| target_apy = pm.Number(0.15, bounds=(0,1), precedence=1) | |
| total_curve_pool_tvl = pm.Number(1e7, bounds=(0,None), precedence=0) | |
| def __init__(self): | |
| super().__init__() | |
| self.app = pn.Param(self.param) | |
| self.update_display_level() | |
| @pm.depends("display_level", watch=True) | |
| def update_display_level(self): | |
| self.app.display_threshold = 2 - self.display_level | |
| p = Protocol() | |
| p.app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment