Skip to content

Commit

Permalink
Fix maximum callstack size exceeded error
Browse files Browse the repository at this point in the history
  • Loading branch information
okld committed May 27, 2022
1 parent e5e4ae9 commit ad224ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
12 changes: 8 additions & 4 deletions streamlit_gallery/components/elements/dashboard/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,27 @@ class Dashboard:

DRAGGABLE_CLASS = "draggable"

_layout = []
def __init__(self):
self._layout = []

def _register(self, item):
self._layout.append(item)

@contextmanager
def __call__(self, **props):
# Draggable classname query selector.
props["draggableHandle"] = f".{Dashboard.DRAGGABLE_CLASS}"

with dashboard.Grid(Dashboard._layout, **props):
with dashboard.Grid(self._layout, **props):
yield

class Item(ABC):

def __init__(self, x, y, w, h, **item_props):
def __init__(self, board, x, y, w, h, **item_props):
self._key = str(uuid4())
self._draggable_class = Dashboard.DRAGGABLE_CLASS
self._dark_mode = True
Dashboard._layout.append(dashboard.Item(self._key, x, y, w, h, **item_props))
board._register(dashboard.Item(self._key, x, y, w, h, **item_props))

def _switch_theme(self):
self._dark_mode = not self._dark_mode
Expand Down
15 changes: 8 additions & 7 deletions streamlit_gallery/components/elements/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ def main():
st.title("")

if "w" not in state:
board = Dashboard()
w = SimpleNamespace(
dashboard=Dashboard(),
editor=Editor(0, 0, 6, 11, minW=3, minH=3),
player=Player(0, 12, 6, 10, minH=5),
pie=Pie(6, 0, 6, 7, minW=3, minH=4),
radar=Radar(12, 7, 3, 7, minW=2, minH=4),
card=Card(6, 7, 3, 7, minW=2, minH=4),
data_grid=DataGrid(6, 13, 6, 7, minH=4),
dashboard=board,
editor=Editor(board, 0, 0, 6, 11, minW=3, minH=3),
player=Player(board, 0, 12, 6, 10, minH=5),
pie=Pie(board, 6, 0, 6, 7, minW=3, minH=4),
radar=Radar(board, 12, 7, 3, 7, minW=2, minH=4),
card=Card(board, 6, 7, 3, 7, minW=2, minH=4),
data_grid=DataGrid(board, 6, 13, 6, 7, minH=4),
)
state.w = w

Expand Down

0 comments on commit ad224ab

Please sign in to comment.