Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs update code griddraggable #888

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,29 @@ def Page():

# some placeholders
items = [ColorCard(title=f"Child {i}", color=colors[i]) for i in range(len(grid_layout))]
with solara.VBox() as main:
resizable = solara.ui_checkbox("Allow resizing", value=True)
draggable = solara.ui_checkbox("Allow dragging", value=True)

def reset_layout():
set_grid_layout(grid_layout_initial)
resizable = solara.ui_checkbox("Allow resizing", value=True)
draggable = solara.ui_checkbox("Allow dragging", value=True)
Comment on lines +37 to +38
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these two should be replaced by solara.Checkbox and explicit state control using solara.use_reactive


solara.Button("Reset to initial layout", on_click=reset_layout)
def reset_layout():
set_grid_layout(grid_layout_initial)

solara.GridDraggable(items=items, grid_layout=grid_layout, resizable=resizable, draggable=draggable, on_grid_layout=set_grid_layout)
solara.Button("Reset to initial layout", on_click=reset_layout)

# some string kung fu to make this print nicely
grid_layout_formatted = pprint.pformat(grid_layout, indent=4)
grid_layout_formatted = textwrap.indent(grid_layout_formatted, " " * len("grid_layout = "))
grid_layout_formatted = grid_layout_formatted[len("grid_layout = ") :]
solara.Markdown(
f"""
# Resulting layout
solara.GridDraggable(items=items, grid_layout=grid_layout, resizable=resizable, draggable=draggable, on_grid_layout=set_grid_layout)

This layout can be copy pasted to put in your code as an initial layout:
# some string kung fu to make this print nicely
grid_layout_formatted = pprint.pformat(grid_layout, indent=4)
grid_layout_formatted = textwrap.indent(grid_layout_formatted, " " * len("grid_layout = "))
grid_layout_formatted = grid_layout_formatted[len("grid_layout = ") :]
solara.Markdown(
f"""
# Resulting layout

```python
grid_layout = {grid_layout_formatted}
```
"""
)
return main
This layout can be copy pasted to put in your code as an initial layout:

```python
grid_layout = {grid_layout_formatted}
```
"""
)
Loading