MarcSkovMadsen
commited on
Commit
·
da6eba7
1
Parent(s):
86873ef
use flexbox
Browse files
app.py
CHANGED
@@ -1,8 +1,7 @@
|
|
1 |
"""The FeatureInput enables a user to select from a list of features and set their values"""
|
2 |
|
3 |
-
import param
|
4 |
-
|
5 |
import panel as pn
|
|
|
6 |
|
7 |
|
8 |
class FeatureInput(pn.widgets.CompositeWidget):
|
@@ -58,13 +57,9 @@ class FeatureInput(pn.widgets.CompositeWidget):
|
|
58 |
@param.depends("features", watch=True, on_init=True)
|
59 |
def _reset_selected_features(self):
|
60 |
selected_features = []
|
61 |
-
for (
|
62 |
-
feature
|
63 |
-
) in self.selected_features.copy():
|
64 |
if feature in self.features.copy():
|
65 |
-
selected_features.append(
|
66 |
-
feature
|
67 |
-
)
|
68 |
|
69 |
self.param.selected_features.objects = list(self.features)
|
70 |
self.selected_features = selected_features
|
@@ -101,6 +96,7 @@ class FeatureInput(pn.widgets.CompositeWidget):
|
|
101 |
pn.bind(self._update_value, widget, watch=True)
|
102 |
return widget
|
103 |
|
|
|
104 |
def create_app():
|
105 |
features = {
|
106 |
"Blade Length (m)": 73.5,
|
@@ -122,12 +118,17 @@ def create_app():
|
|
122 |
styles={"border": "1px solid lightgray", "border-radius": "5px"},
|
123 |
)
|
124 |
|
125 |
-
return pn.
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
|
|
|
|
|
|
|
|
130 |
)
|
131 |
-
|
|
|
132 |
if pn.state.served:
|
133 |
create_app().servable()
|
|
|
1 |
"""The FeatureInput enables a user to select from a list of features and set their values"""
|
2 |
|
|
|
|
|
3 |
import panel as pn
|
4 |
+
import param
|
5 |
|
6 |
|
7 |
class FeatureInput(pn.widgets.CompositeWidget):
|
|
|
57 |
@param.depends("features", watch=True, on_init=True)
|
58 |
def _reset_selected_features(self):
|
59 |
selected_features = []
|
60 |
+
for feature in self.selected_features.copy():
|
|
|
|
|
61 |
if feature in self.features.copy():
|
62 |
+
selected_features.append(feature)
|
|
|
|
|
63 |
|
64 |
self.param.selected_features.objects = list(self.features)
|
65 |
self.selected_features = selected_features
|
|
|
96 |
pn.bind(self._update_value, widget, watch=True)
|
97 |
return widget
|
98 |
|
99 |
+
|
100 |
def create_app():
|
101 |
features = {
|
102 |
"Blade Length (m)": 73.5,
|
|
|
118 |
styles={"border": "1px solid lightgray", "border-radius": "5px"},
|
119 |
)
|
120 |
|
121 |
+
return pn.FlexBox(
|
122 |
+
pn.Column(
|
123 |
+
"## Widget",
|
124 |
+
widget,
|
125 |
+
),
|
126 |
+
pn.Column(
|
127 |
+
"## Value",
|
128 |
+
pn.pane.JSON(widget.param.value, width=500, height=200),
|
129 |
+
),
|
130 |
)
|
131 |
+
|
132 |
+
|
133 |
if pn.state.served:
|
134 |
create_app().servable()
|