Skip to main content

GPU-accelerated 3D scatter plot widget for Tkinter, written in Rust

Project description

tkfastscatter

GPU-accelerated 3D scatter plot widget for Tkinter, written in Rust.

Renders large point clouds (250 k+ points) at interactive frame rates by using wgpu (Vulkan / Metal / DirectX 12) via PyO3. The widget embeds directly in any Tkinter layout — no separate window or subprocess.

Installation

pip install tkfastscatter

Pre-built wheels will be published to PyPI for Python 3.9–3.12 on Windows, macOS, and Linux once a CI release pipeline is in place. Until then, install from source (see Building from source below).

GitHub release publishing

This repo now includes automated PyPI publishing through release.yml. The workflow builds:

  • a source distribution
  • Linux x86_64 manylinux wheels
  • Windows x64 wheels
  • macOS x86_64 and arm64 wheels

Publishing uses PyPI Trusted Publishing. Before the first release, configure tkfastscatter on PyPI to trust this exact GitHub Actions workflow:

  1. Repository owner: NKocur
  2. Repository name: tkfastscatter
  3. Workflow path: .github/workflows/release.yml

After that, publishing a GitHub Release will build artifacts and upload them to PyPI automatically. You can also run the same workflow manually from GitHub Actions via workflow_dispatch; leave publish unchecked for a build-only dry run, or enable it to upload to PyPI.

Quick start

import tkinter as tk
import numpy as np
from tkfastscatter import ScatterWidget

root = tk.Tk()
widget = ScatterWidget(root, width=900, height=700)
widget.pack(fill="both", expand=True)

pts = np.random.default_rng(0).standard_normal((250_000, 3)).astype(np.float32)
widget.set_points(pts, colormap="plasma")

root.mainloop()

API

Widget construction

ScatterWidget(master, *, width=800, height=600, fps=60, vsync=True, **kwargs)

A tk.Frame subclass. All standard frame keyword arguments are forwarded.

Pre-map behaviour: The following may be called before mainloop() and are queued, then replayed when the renderer initialises on widget map: set_points, add_points, add_lines, add_box, scalar_bar, show_orientation_axes, point_style, show_grid, set_background, set_axes, set_ticks, and the parallel_projection property.

Camera methods (reset_camera, view_*, fit, get_camera, set_camera) and overlay-mutation methods (update_lines, remove_overlay, set_overlay_visibility) are silent no-ops before the widget is mapped.


Point clouds

widget.set_points(positions, *, colors=None, scalars=None, colormap="viridis",
                  point_size=4.0, clim=None, nan_color=(0.3,0.3,0.3),
                  log_scale=False, opacity=1.0)

Replace all point actors with a single point cloud. Line overlays are not affected; call clear() first to reset the whole scene.

Parameter Type Description
positions (N, 3) float32 XYZ coordinates
colors (N, 3) float32, optional Per-point RGB in [0, 1]. Takes priority over scalars.
scalars (N,) float32, optional Mapped through colormap. Used when colors is absent.
colormap str One of the names returned by colormap_names().
point_size float Point diameter in pixels (default 4).
clim (float, float), optional Colormap range. Defaults to data min/max.
nan_color (r, g, b) Colour for NaN scalars (default dark grey).
log_scale bool Apply log₁₀ normalisation before colouring.
opacity float Per-call alpha, [0, 1] (default 1.0).
handle = widget.add_points(positions, *, ...)   # same kwargs as set_points
widget.update_actor(handle, positions, *, ...)  # replace in-place
widget.set_actor_visibility(handle, visible)
widget.remove_actor(handle)
widget.clear()                                   # remove all actors, overlays, and grid

Rendering style

widget.point_style = "circle"   # "circle" | "square" | "gaussian"
widget.set_ticks(x=None, y=None, z=None)

Camera

widget.reset_camera()
widget.fit(bounds=None)          # (xmin,ymin,zmin,xmax,ymax,zmax) or re-fit data
widget.view_xy(); widget.view_xz(); widget.view_yz(); widget.view_isometric()
widget.parallel_projection       # bool property
state = widget.get_camera()
widget.set_camera(state)

Axis labels, grid and background

widget.set_axes(x="X", y="Y", z="Z")   # axis title labels at grid extents
widget.show_grid(visible=True)          # toggle grid lines + tick labels
widget.set_background(color)            # (r,g,b) tuple or "#RRGGBB" hex string

Scalar bar

widget.scalar_bar(visible=True, *, vmin=0.0, vmax=1.0, log_scale=False,
                  colormap="viridis", title="")

Line overlays

Segments are (N, 6) float32 arrays, each row [x0,y0,z0, x1,y1,z1]. Overlay bounds are included in camera fitting and grid extents.

handle = widget.add_lines(segments, color=(1,1,1))
handle = widget.add_box(bounds, color=(1,1,0))   # (xmin,ymin,zmin,xmax,ymax,zmax)
widget.update_lines(handle, segments, color)
widget.set_overlay_visibility(handle, visible)
widget.remove_overlay(handle)
widget.clear_overlays()
widget.show_orientation_axes(visible=True)

Picking

widget.enable_point_picking(on_pick=None)      # fires <<PointPicked>>
widget.enable_rectangle_picking(on_select=None) # Shift+drag; fires <<SelectionChanged>>
widget.disable_picking()
# After <<PointPicked>>:  widget.picked_point, .picked_index, .picked_actor
# After <<SelectionChanged>>: widget.selected  →  [{"actor":int,"index":int},...]

Animation export

widget.open_gif(path, fps=20, loop=0)
widget.write_frame()
widget.close_gif()
# or all-in-one orbit:
widget.orbit_gif(path, n_frames=60, fps=20, loop=0, elevation=0.3, on_progress=None)

Screenshot

rgba = widget.screenshot()   # (H, W, 4) uint8 ndarray, or None before map
widget.save_png(path)

Linked cameras

from tkfastscatter import link_cameras, unlink_cameras
link_cameras(w1, w2, w3, ...)
unlink_cameras(w1, w2)

Misc

ScatterWidget.colormap_names()  list[str]

Camera controls

Input Action
Left-drag Orbit
Shift + left-drag Pan
Middle-drag Pan
Scroll wheel Zoom
Double left-click Reset camera

Platform notes

Windows

Fully supported. Uses DirectX 12 or Vulkan via wgpu. No extra dependencies.

macOS

Fully supported. Uses Metal via wgpu. No extra dependencies.

Linux

Requires an X11/Xlib display (Wayland is not supported). The widget uses winfo_id() to obtain an XID and opens the display via libX11.so.6. Pure Wayland sessions will fail at renderer initialisation with a warning. Running under XWayland works.

# Confirm X11 is available:
echo $DISPLAY   # should print e.g. :0

Building from source

Requires Rust (stable) and maturin ≥ 1.7.

Development (installs the extension in-place for local imports):

pip install maturin
maturin develop --release
pytest tests/

Distribution wheel — use the helper script, which removes the maturin develop artifact from the source tree before building. Running maturin build directly from a development working tree will fail because the in-place extension collides with the freshly-compiled one:

python scripts/build_wheel.py           # produces target/wheels/*.whl
# or equivalently:
rm -f python/tkfastscatter/_tkfastscatter*.{pyd,so,dylib}
maturin build --release

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tkfastscatter-0.1.0.tar.gz (60.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tkfastscatter-0.1.0-cp312-cp312-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.12Windows x86-64

tkfastscatter-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

tkfastscatter-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

tkfastscatter-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

tkfastscatter-0.1.0-cp311-cp311-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.11Windows x86-64

tkfastscatter-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

tkfastscatter-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

tkfastscatter-0.1.0-cp311-cp311-macosx_10_12_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

tkfastscatter-0.1.0-cp310-cp310-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.10Windows x86-64

tkfastscatter-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

tkfastscatter-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

tkfastscatter-0.1.0-cp310-cp310-macosx_10_12_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

tkfastscatter-0.1.0-cp39-cp39-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.9Windows x86-64

tkfastscatter-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

tkfastscatter-0.1.0-cp39-cp39-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

tkfastscatter-0.1.0-cp39-cp39-macosx_10_12_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.9macOS 10.12+ x86-64

File details

Details for the file tkfastscatter-0.1.0.tar.gz.

File metadata

  • Download URL: tkfastscatter-0.1.0.tar.gz
  • Upload date:
  • Size: 60.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tkfastscatter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6efbd51a7a48ee2ff5465975896ba4d69b12925574cf0cd27fb3ee8f3d1ddc50
MD5 c02c96a98f43d50640fe6b9b1ae0a817
BLAKE2b-256 96125b34fb1fd58ea2177d32d1c104c7507043d5097c61dc5a7c0b18b1e12948

See more details on using hashes here.

File details

Details for the file tkfastscatter-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for tkfastscatter-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0c43b89cc7233f076cb8161a519c2268d8e60dc959f4f58b7c6d5a14d39d8671
MD5 b65e62a0982ea8c427f9ab7f04ec0e25
BLAKE2b-256 dc06eebda8bf452e1d4a11f6031bbd11a0f83fb2cd98fa7aa489d56db297dcd9

See more details on using hashes here.

File details

Details for the file tkfastscatter-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tkfastscatter-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 71b592833ed4c946468609181d21b1126b75e7ccfad17d50cd294f46502dce71
MD5 d176c00dc0fe254f71fd69440b1dba69
BLAKE2b-256 a231ac429749e90d0d6c281c49466b00bb868a9b7534e52dd823ce8f61bd800a

See more details on using hashes here.

File details

Details for the file tkfastscatter-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tkfastscatter-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5d5e99741edb34d72dfd4ebc083528691b7aba8c969c845ad304766ef59757cb
MD5 90914af424e7fdb48364bfe615586201
BLAKE2b-256 bc13dfdcd631c9f1ac80b2353be457fb571f18aaae509e291ddb79798d9132a7

See more details on using hashes here.

File details

Details for the file tkfastscatter-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for tkfastscatter-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4cabcca50df9d32335089c581e33dffb4a94633096137fa28e73ce37a5b29dd3
MD5 6f68b088ea5927e9fb6faf21a069bf0e
BLAKE2b-256 29f1413998699e726cc788f0b31fe57d7025e8f4cb38d963286598eca998a973

See more details on using hashes here.

File details

Details for the file tkfastscatter-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for tkfastscatter-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 172034202b24c9a01a3f69406de6441474102498f1b8f603b419aadc9dff5a59
MD5 102be13ade985d53da83014babe4164c
BLAKE2b-256 8cdbe614878c24a744ad988f4623bc190f860b158b0b46c6122f70e4a1a4eb08

See more details on using hashes here.

File details

Details for the file tkfastscatter-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tkfastscatter-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e51381f790bec4ed2d95d7662b7db294d0f94b6ba5f7597da478591e297e9cbe
MD5 a2a2cd72c0be40ecdfcaa5de7cf61d65
BLAKE2b-256 429942d4c6b79e8c48d3906e65d6e9cecb66cde27b907448cb3ab02935f4a4a7

See more details on using hashes here.

File details

Details for the file tkfastscatter-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tkfastscatter-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6daebaf8f71f059eb06069fb8fda62a39cd1f5de9f208067e60c178179cc2f20
MD5 61962c7ec97261399f80247dd1fcecfb
BLAKE2b-256 973c70ebea9e8f786c98bf741be9b62e177c3386c6f4caea25d979183e11ee1b

See more details on using hashes here.

File details

Details for the file tkfastscatter-0.1.0-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for tkfastscatter-0.1.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e1a3b84eb6a73616dddf62458c5e50b9e12fe7b69284a0866b7f0f3ed5e7f957
MD5 960e700b77b59a607b207d11876600b5
BLAKE2b-256 d6c21e47aad17edc22e5a9b8a6593609e2795e1cc87faa220daf454711dd5ed5

See more details on using hashes here.

File details

Details for the file tkfastscatter-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for tkfastscatter-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 51ad9f8a3f920c7c940e0970318ead487131ea04d5708574273c24993cbb064d
MD5 b29f49a351e98fd985520a6471ae9cb7
BLAKE2b-256 66dcb86ad7a31b920ddae42a2016778c9b29b3569993dc371bffb3562bfe0894

See more details on using hashes here.

File details

Details for the file tkfastscatter-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tkfastscatter-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d930b1b9ff24f33d71eec1b9bed5425d0bbd0f72f8f348b0b295b306b15253f5
MD5 7a60673009309e65ed16b7ee88968610
BLAKE2b-256 f8ffd251da29fc1c7fad875529eb74a42cc98a5284687e616cba6f65b90c743d

See more details on using hashes here.

File details

Details for the file tkfastscatter-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tkfastscatter-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f686555daeebac0499712afc33afb8bdaf4b64223c2df9dd65025ac3382455cc
MD5 cfb4df8b04102f5f2cf5763d783161e9
BLAKE2b-256 3db72005f37742ee04feef1e8d87486fd2062f01df1ddd5dea188ee0b4e698b2

See more details on using hashes here.

File details

Details for the file tkfastscatter-0.1.0-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for tkfastscatter-0.1.0-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ea6ca10a3588519af71b86190eab9cac8454dd3ad7acd6b94355026fc66feb81
MD5 2376dd6053d743345149a645080e9ca8
BLAKE2b-256 8546f5d85246e441a3c9c1258cff8b1293370e063614dfea61a809f056f0fd69

See more details on using hashes here.

File details

Details for the file tkfastscatter-0.1.0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for tkfastscatter-0.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 08eee509013469654505a6b6149aa4cd60e5a2624e54024e5b96e31bc5ebb1ed
MD5 21b5e54582db18ac5d9070c97303423b
BLAKE2b-256 cc6cb955a55a361ad250836bc1765c36cb9203e5061ebc5f74dbbd8bb574de5b

See more details on using hashes here.

File details

Details for the file tkfastscatter-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tkfastscatter-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bac1b8897de30efc88239cedf5dbafb9def40f44d3428a7ab86f289f4a2258cf
MD5 edaff268b102c9756773d720d0835f3c
BLAKE2b-256 6ae153e6c4d77e84642047883a19debcd6747176854c718bbae2aa40bc334498

See more details on using hashes here.

File details

Details for the file tkfastscatter-0.1.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tkfastscatter-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 457fee3160e43a8ac3d72b3d82e5352e4ebf9fd61e477f887a48fce66dc1fb01
MD5 48d1c237ed5567659026fcc38dcfda44
BLAKE2b-256 68394d4ef1f42026eb6c8bde7d10cbc19cf5bc6eed8ad1be31d304105f017531

See more details on using hashes here.

File details

Details for the file tkfastscatter-0.1.0-cp39-cp39-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for tkfastscatter-0.1.0-cp39-cp39-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5657e3102667afd5459d62cd890c7a25b1b9aa5836cf788e99bd6f42f0284a40
MD5 8b083b4523d8eeff6f998833b9f50253
BLAKE2b-256 55928f3184d3c8c72a71805f4d744754f7f899f68d2cba1951fcae234f035129

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page