Module for remote-controlling the tev image viewer.
Project description
tevclient 
Module for remote-controlling the tev image viewer. This module implements tev's IPC protocol, allowing you to control tev via a TCP connection. You can create, modify, reload, and close images as well as overlay vector graphics.
The initial version of this module was written by Tomáš Iser and contributed to tev.
Installation
pip install tevclient
Usage
Enter a context via the Ipc class (or an async context using IpcAsync), which will handle the connection to tev.
Then instrument tev by calling the various methods of the context.
import tevclient
with tevclient.Ipc() as tev_ipc:
# or: async with tevclient.IpcAsync() as tev_ipc:
# Open an image
tev_ipc.open_image("path/to/image.png")
# or: await tev_ipc.open_image("path/to/image.png")
# Create a new image
tev_ipc.create_image("My Image", width=800, height=600, channel_names=["R", "G", "B"])
# Update the image with pixel data
import numpy as np
image_data = np.random.rand(600, 800, 3) # Random RGB data
tev_ipc.update_image("My Image", image_data, ["R", "G", "B"])
# Close the image
tev_ipc.close_image("My Image")
The following methods are available:
| Operation | Function |
|---|---|
open_image |
Opens an image from a specified path on the machine tev is running on. |
create_image |
Creates a blank image with a specified name, size, and set of channels. If an image with the specified name already exists, it is overwritten. |
update_image |
Updates the pixels in a rectangular region. |
close_image |
Closes a specified image. |
reload_image |
Reloads an image from a specified path on the machine tev is running on. |
update_vector_graphics |
Draws vector graphics over a specified image. |
Each method comes with type annotations and a docstring, so should be self-explanatory when used in an IDE.
Examples
More complete examples than the one above can be found in the examples/ directory of this repository.
Below is an excerpt that showcases tilewise updating of an image and drawing vector graphics over it.
import time
import numpy as np
import tevclient
with tevclient.Ipc() as tev_ipc:
# Create sample image in one go. The image will have RGB channels (displayed as one layer)
# as well as a 'Bonus' channel (displayed as another layer)
image_data = np.full((300, 200, 3), 1.0)
image_data[40:61, :, 0] = 0.0
image_data[:, 40:61, 1] = 0.0
image_data[50:71, 50:71, 2] = 0.0
bonus_data = image_data[:, :, 0] + image_data[:, :, 1] + image_data[:, :, 2]
tev_ipc.create_image("Test image 1", width=200, height=300, channel_names=["R", "G", "B", "Bonus"])
tev_ipc.update_image("Test image 1", image_data, ["R", "G", "B"])
tev_ipc.update_image("Test image 1", bonus_data, ["Bonus"])
# Create another image that will be populated over time
RESOLUTION = 256
TILE_SIZE = 64
N_TILES = (RESOLUTION // TILE_SIZE) ** 2
tev_ipc.create_image("Test image 2", width=RESOLUTION, height=RESOLUTION, channel_names=["R", "G", "B"])
idx = 0
for y in range(0, RESOLUTION, TILE_SIZE):
for x in range(0, RESOLUTION, TILE_SIZE):
tile = np.full((TILE_SIZE, TILE_SIZE, 3), idx / N_TILES)
tev_ipc.update_image("Test image 2", tile, ["R", "G", "B"], x, y)
# Display a rectangle where the tile was updated
tev_ipc.update_vector_graphics(
"Test image 2",
[
tevclient.vg_begin_path(),
tevclient.vg_rect(x, y, TILE_SIZE, TILE_SIZE),
# Alternatively: draw rectangle manually
# tevclient.vg_move_to(x, y),
# tevclient.vg_line_to(x, y + TILE_SIZE),
# tevclient.vg_line_to(x + TILE_SIZE, y + TILE_SIZE),
# tevclient.vg_line_to(x + TILE_SIZE, y),
# tevclient.vg_close_path(),
tevclient.vg_stroke(),
],
)
idx += 1
time.sleep(0.1)
License
BSD 3-Claude; see LICENSE for details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tevclient-1.0.3.tar.gz.
File metadata
- Download URL: tevclient-1.0.3.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0002b9f43f0e724705b1b9d66dd8b9d6e387d8a644c9053c62ac28f48d583343
|
|
| MD5 |
e28bfaa071ac2b9d8618799a5fb18167
|
|
| BLAKE2b-256 |
362793a612700ce37a929c59c4079230b7a927fa562f6fa299d5e2fa957b4f04
|
Provenance
The following attestation bundles were made for tevclient-1.0.3.tar.gz:
Publisher:
pypi.yml on Tom94/tevclient
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tevclient-1.0.3.tar.gz -
Subject digest:
0002b9f43f0e724705b1b9d66dd8b9d6e387d8a644c9053c62ac28f48d583343 - Sigstore transparency entry: 253046236
- Sigstore integration time:
-
Permalink:
Tom94/tevclient@71d9c258b0ebb036d36d6355fb1785ee23703a4e -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/Tom94
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@71d9c258b0ebb036d36d6355fb1785ee23703a4e -
Trigger Event:
push
-
Statement type:
File details
Details for the file tevclient-1.0.3-py3-none-any.whl.
File metadata
- Download URL: tevclient-1.0.3-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c96c4995ccbf3695907e7af713d69a63dbc84d642d6efda84330720771dab098
|
|
| MD5 |
2f91e197565c2b5dcb4c3282276d77cf
|
|
| BLAKE2b-256 |
63266c6c580a0cba066a9a756b85bf97653b2fda8cadd976c63ac78f1ec21090
|
Provenance
The following attestation bundles were made for tevclient-1.0.3-py3-none-any.whl:
Publisher:
pypi.yml on Tom94/tevclient
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tevclient-1.0.3-py3-none-any.whl -
Subject digest:
c96c4995ccbf3695907e7af713d69a63dbc84d642d6efda84330720771dab098 - Sigstore transparency entry: 253046238
- Sigstore integration time:
-
Permalink:
Tom94/tevclient@71d9c258b0ebb036d36d6355fb1785ee23703a4e -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/Tom94
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@71d9c258b0ebb036d36d6355fb1785ee23703a4e -
Trigger Event:
push
-
Statement type: