50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
from utils.path_utils import get_assets_dir
|
|
from PIL import Image, ImageDraw
|
|
|
|
# 상수: 아이콘 파일명
|
|
APP_ICON_NAME = "app_icon.png"
|
|
|
|
class AssetLoader:
|
|
"""
|
|
애플리케이션 자산(이미지, 아이콘 등)을 로드하고 관리하는 유틸리티 클래스.
|
|
"""
|
|
|
|
@staticmethod
|
|
def get_assets_dir():
|
|
"""자산(assets) 디렉토리의 절대 경로를 반환합니다."""
|
|
return get_assets_dir()
|
|
|
|
@staticmethod
|
|
def get_app_icon_path():
|
|
"""
|
|
애플리케이션 아이콘 파일의 절대 경로를 반환합니다.
|
|
|
|
Returns:
|
|
str: 아이콘 파일 경로 문자열 (Tkinter 등에서 사용 용이하도록 str 변환)
|
|
"""
|
|
icon_path = AssetLoader.get_assets_dir() / APP_ICON_NAME
|
|
return str(icon_path)
|
|
|
|
@staticmethod
|
|
def get_tray_icon_image():
|
|
"""
|
|
시스템 트레이에 사용할 PIL Image 객체를 반환합니다.
|
|
|
|
파일 로드에 실패할 경우 파란색 원형 아이콘을 동적으로 생성하여 반환합니다.
|
|
|
|
Returns:
|
|
PIL.Image: 트레이 아이콘 이미지
|
|
"""
|
|
path = AssetLoader.get_app_icon_path()
|
|
try:
|
|
return Image.open(path)
|
|
except Exception as e:
|
|
print(f"[UI] 아이콘 로드 실패 ({path}): {e}")
|
|
# 실패 시 기본 이미지 생성 (파란색 원)
|
|
img = Image.new('RGBA', (64, 64), (0, 0, 0, 0))
|
|
d = ImageDraw.Draw(img)
|
|
d.ellipse((8, 8, 56, 56), fill="#3B8ED0", outline="white")
|
|
return img
|
|
|
|
asset_loader = AssetLoader()
|