Skip to content

Commit

Permalink
fix(deckgl): Wrap deckgl module from pywebvue
Browse files Browse the repository at this point in the history
  • Loading branch information
DrewLazzeriKitware committed Oct 4, 2021
1 parent 222ca66 commit 0cf9a54
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions trame/deckgl/__init__.py
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))

0 comments on commit 0cf9a54

Please sign in to comment.