Skip to content

modularizer/custom_filetype

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

custom_filetype

Tools for registering custom filetypes to the system.

Features

  • The default application to launch when opening a file
    • Windows
    • Linux
  • Context menu actions when you right click a file
    • Windows
    • Linux
  • Thumbnail icon for each file in the file explorer
    • Windows
    • Linux
  • File preview in the preview tab
    • Windows
    • Linux

Usage

from typing import Literal
from custom_filetype import register_custom_filetype, ThumbnailProvider


class CustomFileTypeThumbnailProvider(ThumbnailProvider):
    def get_thumbnail_bytes(self, cx) -> tuple[bytes, Literal['bmp', 'png']]:
        """Return the thumbnail bytes and format

        Args:
            cx (int): The width and height of the thumbnail

        Returns:
            bytes: The thumbnail bytes
            str: The thumbnail format (bmp or png)
        """
        # TODO: Implement this
        raise NotImplementedError("This method must be implemented, to return png_bytes, 'png'")


register_custom_filetype(".cft",
                         "CustomFileType",
                         str((Path(__file__).parent / "viewer.py").resolve()),
                         CustomFileTypeThumbnailProvider,
                         {"Run My Script": "--context-menu"})

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages