Skip to main content

Allows you to visualize objects with html on a 2D canvas with the desired color, caption (on hover), and image of the object (on click).

Project description

KanvasObjectKlick

KanvasObjectKlick allows you to visualize objects with html on a 2D canvas with the desired color, caption (on hover), and image of the object (on click).

Installation

python3 -m pip install --upgrade pip
pip3 install KanvasObjectKlick

Usage

import random
from KanvasObjectKlick import KOKEntity, build_a


keks = []
for i in range(random.randint(3, 50)):
    # name/description of object. It will be displayed when the mouse cursor is hovered over.
    name_i = f"name_{i}"
    
    # x and y, can be float and any range
    coords_i = (random.randint(-1000, 1000)+random.random(), random.randint(-1000, 1000)+random.random())  
    
    # RGB color
    color_i = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))  
    
    # instead of None you can use Pillow, OpenCV image or just path to picture file
    img_i = None  
    
    # Just create KOKEntity
    kok = KOKEntity(name=name_i, coords=coords_i, color=color_i, img=img_i)
    
    keks.append(kok)

# It will create `/path/to/out/file.html` file. Just open it in your browser.
build_a(keks, "/path/to/out/file", zip_need=False)

You can also create zip file with zip_need=True. In this case, file /path/to/out/file.zip will be created.

Instead build_a you can use build_b (from KanvasObjectKlick import build_b). It will create zip with no all in one file. This can be useful when there are too many objects (or rather their images).

# ...

from KanvasObjectKlick import build_b

# It will create `/path/to/out/file.zip` file. Just extract it and open `index.html` in your browser.
build_b(keks, "/path/to/out/file", "/path/to/working/dir")

/path/to/working/dir can be any directory. It is needed in order to stack temporary files while working. In the end, there will be no garbage left, everything superfluous will be removed.

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

kanvasobjectklick-0.0.3.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

kanvasobjectklick-0.0.3-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file kanvasobjectklick-0.0.3.tar.gz.

File metadata

  • Download URL: kanvasobjectklick-0.0.3.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for kanvasobjectklick-0.0.3.tar.gz
Algorithm Hash digest
SHA256 aeb4e8a6f1076c7b1e308b092ba14be5bddfcc9e95ad2da2b772a2b80df39969
MD5 301c3877d3e622b9cabf46881e0e8d7f
BLAKE2b-256 bc6939765df33e7654387aadc96e9c732ab0a4ba62ceb7e0743dd1c785c4095c

See more details on using hashes here.

File details

Details for the file kanvasobjectklick-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for kanvasobjectklick-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4a563396386542abe66440cd97e1c0367e8631480208d5d5ef1648e81a633dfe
MD5 4ee6d2f7b9225c266a2ba26551e12bec
BLAKE2b-256 b9b8b917e5faa924b494a2db33000b521a04c41f5255df302daca02509a84f95

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