Skip to content

koaning/wigglystuff

Repository files navigation

wigglystuff

"A collection of creative AnyWidgets for Python notebook environments."

The project uses anywidget under the hood so our tools should work in Jupyter, Shiny for Python, VSCode, Colab, Solara and Marimo. Because of the anywidget integration you should also be able interact with ipywidgets natively.

Online demos

We've made some demos of the widgets and shared them on the Marimo gallery for easy exploration.

Matrix demo with PCA Tangle Widgets for exploration


Installation

Installation occurs via pip or uv.

python -m pip install wigglystuff
uv pip install wigglystuff

Usage

Slider2D

from wigglystuff import Slider2D

widget = Slider2D()
widget

This widget allows you to grab the widget.x and widget.y properties to get the current position of the slider. But you can also use the widget.observe method to listen to changes in the widget.

Example of widget.observe
import ipywidgets
from wigglystuff import Slider2D

widget = Slider2D()
output = ipywidgets.Output()
state = [[0.0, 0.0]]

@output.capture(clear_output=True)
def on_change(change):
    if abs(widget.x - state[-1][0]) > 0.01:
        if abs(widget.y - state[-1][1]) > 0.01:
            state.append([widget.x, widget.y])
    for elem in state[-5:]:
        print(elem)

widget.observe(on_change)
on_change(None)
ipywidgets.HBox([widget, output])

Matrix

If you want to get an intuition of linear algebra, the Matrix object might really help. It can generate a matrix for you that allows you to update all the values in it.

from wigglystuff import Matrix

arr = Matrix(rows=1, cols=2, step=0.1)
mat = Matrix(matrix=np.eye(2), mirror=True, step=0.1)

TangleSlider

Sliders are neat, but maybe you'd prefer to have something more inline. For that use-case the TangleSlider can be just what you need.

from wigglystuff import TangleSlider

TangleChoice & TangleSelect

This is similar to the TangleSlider but for discrete choices.

from wigglystuff import TangleChoice

TangleSelect is just like TangleChoice but with a dropdown.

from wigglystuff import TangleSelect

CopyToClipboard

This is a simple button, but one that allows you to copy anything of interest to the clipboard. This can be very helpful for some interactive Marimo apps where the output needs to be copied into another app.

from wigglystuff import CopyToClipboard

CopyToClipboard("this can be copied")

About

A collection of creative AnyWidgets for Python notebook environments

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published