-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(deckgl): Wrap deckgl module from pywebvue
- Loading branch information
1 parent
222ca66
commit 0cf9a54
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from trame import get_app_instance | ||
from trame.html import AbstractElement | ||
from pywebvue.modules import Deck | ||
import json | ||
|
||
# Make sure used module is available | ||
_app = get_app_instance() | ||
_app.enableModule(Deck) | ||
|
||
|
||
class Deck(AbstractElement): | ||
@staticmethod | ||
def to_jsonInput(deck): | ||
return json.loads(deck.to_json()) | ||
|
||
def __init__(self, name=None, deck=None, **kwargs): | ||
super().__init__("Deck", **kwargs) | ||
self._deck = deck | ||
self._attr_names += ["mapboxApiKey", "tooltip", "customLibraries"] | ||
self._name = name or f"deck_{self._id}" | ||
self._attributes["jsonInput"] = f':jsonInput="{self._name}"' | ||
self.update(deck) | ||
|
||
def update(self, deck=None): | ||
if deck: | ||
self._deck = deck | ||
if self._deck: | ||
_app = get_app_instance() | ||
_app.set(self._name, Deck.to_jsonInput(self._deck)) |