Skip to main content

tkmap

A Tkinter-based interactive map widget for Python, supporting OpenStreetMap and custom tile sources. Easily embed a map in your Tkinter GUI, handle user interaction, and respond to map events.

Features

  • Fast, smooth map panning and zooming
  • Customizable tile sources (e.g., OpenStreetMap)
  • Mouse and viewport event handling
  • Simple integration with Tkinter applications

Installation

Install via pip (after cloning or when available on PyPI):

pip install tkmap

Minimal Example

This example launches a Tkinter window with an interactive OpenStreetMap viewer:

import tkinter as tk
from pathlib import Path
import requests
from platformdirs import user_cache_dir
from tkmap import LonLat, MapWidget
from tkmap.tileloaders.default import DefaultTileLoader

def main():
    tile_loader = DefaultTileLoader(
        url="https://tile.openstreetmap.org/{z}/{x}/{y}.png",
        base_cache_dir=Path(user_cache_dir("tkmap")) / "tile_cache",
        requests_session=requests.Session(),
    )
    root = tk.Tk()
    root.geometry("800x600")
    root.title("tkmap OpenStreetMap Demo")
    map_widget = MapWidget(
        root,
        center=LonLat(0, 0),
        zoom=2,
        tile_loader=tile_loader,
    )
    map_widget.pack(fill="both", expand=True)
    tile_loader.start_remote_fetch_queue_processing(root.winfo_toplevel(), interval_ms=100)
    root.mainloop()

if __name__ == "__main__":
    main()

Handling Events

You can respond to mouse movement and viewport changes using event callbacks:

from tkmap.events import MouseMovedEvent, ViewportChangeEvent

# ... (setup code as above)

def on_mouse_moved(event: MouseMovedEvent):
    print(f"Mouse at lat={event.lonlat.lat:.6f}, lon={event.lonlat.lon:.6f}")

def on_viewport_changed(event: ViewportChangeEvent):
    print(f"Viewport center: {event.center.lat:.6f}, {event.center.lon:.6f}, zoom={event.zoom}")

map_widget.on_mouse_moved(on_mouse_moved)
map_widget.on_viewport_change(on_viewport_changed)

License

Apache-2.0

Metadata

Release files for tkmap 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tkmap 0.1.2
File Size Uploaded Provenance Actions
tkmap-0.1.2.tar.gz 15.6 kB Without provenance Details for tkmap-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tkmap 0.1.2
File Interpreter ABI Platform Actions
tkmap-0.1.2-py3-none-any.whl Python 3 none any Details for tkmap-0.1.2-py3-none-any.whl

Total release size: 38.2 kB

Release files / tkmap-0.1.2.tar.gz

Download URL tkmap-0.1.2.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7fbca6544dbc5e577c2c65d5c35879cdd1ace5f95286652600ad488f7b8b475f
BLAKE2b-256 checksum
How to use checksums
9ba54b65a7a511dd1e02e9d7042a1c7b0b273fb05f3391d285d294b769be5e10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.3 Linux/6.11.0-1015-azure

Release files / tkmap-0.1.2-py3-none-any.whl

Download URL tkmap-0.1.2-py3-none-any.whl
Size 22.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9ff6f42062057bea5e3d119b6603de2ee3870cd884a24d8f2187e0068f0bbdd
BLAKE2b-256 checksum
How to use checksums
08ecfb9ea23cdfdebf26291235679634c4feb144dfdfd116a311fe934fc48fd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.3 Linux/6.11.0-1015-azure

Security for tkmap 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page