HoverZoom API#
Bases: AnyWidget
Image widget with a magnified side panel that appears on hover.
Hovering over the image shows a rectangle indicator and a zoom panel to the right displaying the magnified region — the classic e-commerce product zoom pattern.
Examples:
from wigglystuff import HoverZoom
# From a file path
widget = HoverZoom("photo.jpg", zoom_factor=3.0)
# From a matplotlib figure
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.scatter(x, y, s=5, alpha=0.5)
widget = HoverZoom(fig, zoom_factor=4.0)
Create a HoverZoom widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Optional[Union[str, Path, Any]]
|
Image source — matplotlib figure, file path, URL, PIL Image, bytes, or base64 string. |
None
|
zoom_factor
|
float
|
Magnification level for the zoom panel. |
3.0
|
width
|
int
|
Display width of the source image in pixels. |
500
|
height
|
int
|
Display height in pixels (0 = auto, preserve aspect ratio). |
0
|
Source code in wigglystuff/hover_zoom.py
get_pil_zoom #
Return the currently zoomed region as a PIL Image.
Returns the cropped portion of the image that is visible in the
zoom panel. Returns None if no image is set.
Source code in wigglystuff/hover_zoom.py
Synced traitlets#
| Traitlet | Type | Notes |
|---|---|---|
image |
str |
Base64-encoded image data. |
zoom_factor |
float |
Magnification level for the zoom panel. |
width |
int |
Display width of the source image in pixels. |
height |
int |
Display height in pixels (0 = auto). |