Skip to content

Commit 6555b1c

Browse files
committed
[Python] - Initial commit for panel title contribution
1 parent 5d8898e commit 6555b1c

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

dashipy/dashipy/contribs/panel.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
from typing import Any
2+
13
from dashipy.lib import Contribution
24

35

46
class Panel(Contribution):
57
"""Panel contribution"""
8+
def __init__(self, name: str, title: str):
9+
super().__init__(name)
10+
self.title = title
11+
12+
def to_dict(self) -> dict[str, Any]:
13+
return {
14+
**super().to_dict(),
15+
"title": self.title
16+
17+
}

dashipy/dashipy/lib/extension.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ def decorator(function: Callable) -> Callable:
4646

4747
return decorator
4848

49+
def __str__(self):
50+
return self.name
51+
4952

5053
class Extension:
5154
"""A UI Extension."""

dashipy/dashipy/server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
DASHI_EXTENSIONS_KEY = "dashi.extensions"
1818
DASHI_CONTRIBUTION_POINTS_KEY = "dashi.contribution_points"
1919

20+
# This would done by extension of xcube server
2021
Extension.add_contrib_point("panels", Panel)
2122

2223

dashipy/my_extension/my_panel_1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from dashipy.lib import Output, Input, Component
88

99

10-
panel = Panel(__name__)
10+
panel = Panel(__name__, title="Panel A")
1111

1212

1313
@panel.layout()

dashipy/my_extension/my_panel_2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from dashipy.lib import Output, Input, Component
88

99

10-
panel = Panel(__name__)
10+
panel = Panel(__name__, title="Panel B")
1111

1212

1313
@panel.layout()

0 commit comments

Comments
 (0)