Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Calendar Data Visualisation

Terminal interface to visualise calendar data.

Install

This package is available on pypi. Install with your prefered package manager.

pip install calendardataviz
# or
uv add calendardataviz

Usage

In your project, create a script that implements the InspectorABC class make it return RichString class instances then call the start_app function. You can read our demos in available in the demos folder. Here is a presentation of the different classes and functions:

RichString

A class used to define a background and foreground color along side a string.

class RichString(ttk.TTkString):
    """String class offering the possiblity to define a
    background and foreground color along a string.

    In practice, is an easy to use interface for the
    TermTk.TTkString class, and only override its init method.
    """

    def __init__(
        self,
        text: str,
        bg_color: str | tuple[int, int, int] | tuple[float, float, float] = "#000000",
        fg_color: str | tuple[int, int, int] | tuple[float, float, float] = "#ffffff",
    ) -> None:
        """
        Args:
            text: Text.
            bg_color: Background color, either as an hexadecimal value
                such as `#ff00ff` or as a tuple of values, `(255, 0, 255)`.
            fg_color: Foreground color, in the same format as bg_color.
        """

InspectorABC

Abstract base class you need to implement. It has 3 method to override:

  • color_for_date wich returns the color for a given date.
  • as_color_bar wich returns values for a color bar of a given size.
  • popup_content wich returns content for the popup displayed when the user clicks on a date.

Described in more details in the script template available bellow.

start_app

Entry point for the app, starts the Terminal User Interface.

def start_app(
    inspector_cls: type[InspectorABC],
    years: Sequence[int],
    nb_processes: int = 1,
    target_nb_files: int | None = None,
    root_dir: Path | None = None,
) -> None:
    """Library entry point, instantiates and starts the terminal interface.
    If target_nb_files and root_dir are given, also spawns a file count
    widget, wich displays informations about the file count and the
    completion percentage (nb of files in root dir / target_nb_files).

    Args:
        inspector_cls: Your project's implementatino of the
            `calendardataviz.InspectorABC`. This is the class
            used by the app to get information for each dates.
        years: A sequence of years. A calendar will be displayed
            for each year.
        nb_processes: Number of multiprocessing processes to use.
            If your inspector's `color_for_date` method is not
            instantaneous, helps speed up the calendar's initialisation.
        target_nb_files: If given with `root_dir`, will spawn a
            file count widget.
        root_dir: If given with `target_nb_files`, will spawn a
            file count widget.
    """

Script template

Here is a script template you can copy to start your own implementation of the InspectorABC class.

"""Demonstration of a rainbow calendar.
Shows how to implement an `InspectorABC`
class and run the Terminal User Interface
to interact with it.
"""

import datetime as dt
from typing import override

from calendardataviz import InspectorABC, RichString, start_app


class YourInspector(InspectorABC):
    name = "my inspector"

    @override
    def color_for_date(self, date: dt.date) -> RichString:
        """Returns the color for a given date.

        Args:
            date: date.

        Returns:
            RichString: The text and color associated
                to the given date.
        """
        pass

    @override
    def as_color_bar(self, size: int) -> list[RichString]:
        """Returns values for a color bar of the given size.

        Args:
            size: Size of the colorbar to generate.

        Returns:
            list[RichString]: A list of length "size"
                containing one character TTkStrings, one
                for each cell of the color bar.
        """
        pass

    @override
    def popup_content(self, date: dt.date) -> tuple[str, str]:
        """Return the information displayed when a date is selected.

        Args:
            date: Date selected.

        Returns:
            str: The pop-up window title.
            str: The pop-up window content.
        """
        pass


if __name__ == "__main__":
    start_app(
        inspector_cls=YourInspector,
        years=[2024, 2025, 2026],
        nb_processes=1,
    )

Contribution

Please contribute by proposing a merger request.

You can install the project in development mode like so:

git clone https://github.com/meteofrance/calendardataviz.git
cd calendardataviz
uv sync --all-extras

To format then test your code:

uvx ruff format
uvx ruff check --fix
uv run pytest -s

Once your code is formated and tested, you can create a merge request of your branch into the main branch.

Download files

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

Source Distribution

calendardataviz-0.1a1.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

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

calendardataviz-0.1a1-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file calendardataviz-0.1a1.tar.gz.

File metadata

  • Download URL: calendardataviz-0.1a1.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for calendardataviz-0.1a1.tar.gz
Algorithm Hash digest
SHA256 a4bdf2e11acd5a4f53b2f4bb2b621eb506e75b18140924bd8ec714c568d5fdd0
MD5 7a05d7243dd4cc657fed229120f1ec72
BLAKE2b-256 312811e14fbc972c1b070f5efe7f00e14713308c00a9fd33c01698081c581bff

See more details on using hashes here.

Provenance

The following attestation bundles were made for calendardataviz-0.1a1.tar.gz:

Publisher: release.yml on meteofrance/calendardataviz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file calendardataviz-0.1a1-py3-none-any.whl.

File metadata

  • Download URL: calendardataviz-0.1a1-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for calendardataviz-0.1a1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ae7489f38e556eb3386da927eb830feb08cee2ae97cd91df41518692f0c3271
MD5 e6875c1b87914f05de310007e3620be1
BLAKE2b-256 565627d7abd85a78c0fb091be95e486abf07377102990d1b7ece35bd801a1b6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for calendardataviz-0.1a1-py3-none-any.whl:

Publisher: release.yml on meteofrance/calendardataviz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

This release

0.1a1 This release

2 files

0.0.0

2 files

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