File: icon.py

package info (click to toggle)
python-moderngl-window 3.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 69,096 kB
  • sloc: python: 12,076; makefile: 21
file content (27 lines) | stat: -rw-r--r-- 833 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from pathlib import Path

from moderngl_window.finders import texture
from moderngl_window.loaders.base import BaseLoader
from moderngl_window.meta.base import ResourceDescription
from moderngl_window.meta.texture import TextureDescription


class IconLoader(BaseLoader):
    kind = "icon"
    meta: TextureDescription

    def __init__(self, meta: ResourceDescription) -> None:
        super().__init__(meta)

    def find_icon(self) -> Path:
        """Find resource using texture finders.

        This is mainly a shortcut method to simplify the task.

        Args:
            path: Path to resource
        """
        abs_path = self._find(self.meta.path, texture.get_finders())
        if abs_path is None:
            raise ValueError("Could not find the icon specified. {}".format(self.meta.path))
        return abs_path