Skip to content

Instantly share code, notes, and snippets.

@allieus
Created October 8, 2025 14:50
Show Gist options
  • Save allieus/86109c5f51045488f54f97ce1cc32ab6 to your computer and use it in GitHub Desktop.
Save allieus/86109c5f51045488f54f97ce1cc32ab6 to your computer and use it in GitHub Desktop.
ABC부트캠프 Python 강의 - 대시보드 설정 파일 (테마 & 레이아웃)
# ABC부트캠프 Python 강의 - 대시보드 설정 파일
# 색상 테마와 레이아웃 설정을 관리합니다
# ========================================
# 색상 테마 설정
# ========================================
# 기본 테마 (파란색 계열)
DEFAULT_THEME = {
"header_bg": "#2E5984", # 헤더 배경색
"header_text": "#FFFFFF", # 헤더 텍스트색
"title_bg": "#4472C4", # 제목 배경색
"title_text": "#FFFFFF", # 제목 텍스트색
"chart_color1": "#5B9BD5", # 차트 색상 1
"chart_color2": "#ED7D31", # 차트 색상 2
"chart_color3": "#A5A5A5", # 차트 색상 3
"grid_line": "#D9D9D9" # 그리드 라인색
}
# 다크 테마 (어두운 색 계열)
DARK_THEME = {
"header_bg": "#1F2937",
"header_text": "#F9FAFB",
"title_bg": "#374151",
"title_text": "#F9FAFB",
"chart_color1": "#3B82F6",
"chart_color2": "#F59E0B",
"chart_color3": "#10B981",
"grid_line": "#4B5563"
}
# 그린 테마 (녹색 계열)
GREEN_THEME = {
"header_bg": "#065F46",
"header_text": "#FFFFFF",
"title_bg": "#059669",
"title_text": "#FFFFFF",
"chart_color1": "#10B981",
"chart_color2": "#34D399",
"chart_color3": "#6EE7B7",
"grid_line": "#D1FAE5"
}
# 퍼플 테마 (보라색 계열)
PURPLE_THEME = {
"header_bg": "#5B21B6",
"header_text": "#FFFFFF",
"title_bg": "#7C3AED",
"title_text": "#FFFFFF",
"chart_color1": "#8B5CF6",
"chart_color2": "#A78BFA",
"chart_color3": "#C4B5FD",
"grid_line": "#EDE9FE"
}
# ========================================
# 레이아웃 설정
# ========================================
LAYOUT = {
# 헤더
"header_height": 40,
"header_font_size": 20,
# 차트 제목
"title_height": 30,
"title_font_size": 14,
# 차트 크기
"chart_width": 280,
"chart_height": 200,
# 차트 위치 (셀 범위)
"chart_positions": {
"genre": "A4", # 장르별 차트
"publisher": "E4", # 배급사 차트
"year": "A14", # 연도별 차트
"platform": "E14" # 플랫폼 차트
}
}
# ========================================
# 차트 설정
# ========================================
CHART_TYPES = {
"genre": "column_clustered", # 세로 막대형
"publisher": "bar_clustered", # 가로 막대형
"year": "line", # 꺾은선형
"platform": "pie" # 원형
}
# ========================================
# 데이터 설정
# ========================================
DATA_CONFIG = {
# 상위 N개 데이터만 표시
"top_n": {
"publisher": 10, # Top 10 배급사
"platform": 8 # Top 8 플랫폼
},
# 집계 방법
"aggregation": {
"genre": "sum", # 장르별 판매량 합계
"publisher": "sum", # 배급사별 판매량 합계
"year": "sum", # 연도별 판매량 합계
"platform": "count" # 플랫폼별 게임 수
}
}
# ========================================
# 사용 예시
# ========================================
def get_theme(theme_name="default"):
"""
테마 가져오기
Args:
theme_name: 테마 이름 ("default", "dark", "green", "purple")
Returns:
dict: 테마 색상 딕셔너리
"""
themes = {
"default": DEFAULT_THEME,
"dark": DARK_THEME,
"green": GREEN_THEME,
"purple": PURPLE_THEME
}
return themes.get(theme_name, DEFAULT_THEME)
# ========================================
# 사용자 정의 색상 추출 (PowerPoint 방식)
# ========================================
def extract_colors_from_image(image_path):
"""
이미지에서 색상 추출 (고급 사용)
PowerPoint의 스포이트 도구 대신 Python으로 색상 추출
Args:
image_path: 이미지 파일 경로
Returns:
list: 추출된 주요 색상 리스트 (HEX 코드)
"""
try:
from PIL import Image
import collections
# 이미지 로드
img = Image.open(image_path)
img = img.convert('RGB')
img = img.resize((150, 150)) # 성능을 위해 크기 축소
# 픽셀 색상 수집
pixels = list(img.getdata())
most_common = collections.Counter(pixels).most_common(5)
# HEX 코드로 변환
hex_colors = ['#{:02x}{:02x}{:02x}'.format(r, g, b) for (r, g, b), count in most_common]
return hex_colors
except ImportError:
print("⚠️ PIL 라이브러리가 필요합니다: pip install Pillow")
return []
except Exception as e:
print(f"❌ 색상 추출 실패: {e}")
return []
if __name__ == "__main__":
# 설정 예시 출력
print("📋 사용 가능한 테마:")
for theme_name in ["default", "dark", "green", "purple"]:
print(f"\n{theme_name.upper()} THEME:")
theme = get_theme(theme_name)
for key, value in theme.items():
print(f" {key}: {value}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment