h-1.flet.3/app_hierarchical_product_master.py

133 lines
4.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
階層構造商品マスターデモアプリケーション
入れ子構造とPDF巨大カッコ表示に対応
"""
import flet as ft
import signal
import sys
import logging
from components.hierarchical_product_master import create_hierarchical_product_master
class HierarchicalProductMasterApp:
"""階層構造商品マスターデモアプリケーション"""
def __init__(self, page: ft.Page):
self.page = page
# ログ設定
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('app.log'),
logging.StreamHandler()
]
)
# シグナルハンドラ設定
def signal_handler(signum, frame):
print(f"\nシグナル {signum} を受信しました")
print("✅ 正常終了処理完了")
logging.info("アプリケーション正常終了")
sys.exit(0)
self.signal_handler = signal_handler
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
# ウィンドウ設定
page.title = "階層構造商品マスター"
page.window_width = 1400
page.window_height = 800
page.theme_mode = ft.ThemeMode.LIGHT
# ウィンドウクローズイベント
page.on_window_close = lambda _: signal_handler(0, None)
# 階層商品マスター作成
self.product_master = create_hierarchical_product_master(page)
# ヘッダー
self.header = ft.Container(
content=ft.Column([
ft.Row([
ft.Icon(
ft.Icons.INVENTORY_2,
size=40,
color=ft.Colors.BLUE_900
),
ft.Column([
ft.Text(
"階層構造商品マスター",
size=28,
weight=ft.FontWeight.BOLD,
color=ft.Colors.BLUE_900
),
ft.Text(
"入れ子構造とPDF巨大カッコ表示に対応した商品管理システム",
size=14,
color=ft.Colors.GREY_600
)
], spacing=5)
], alignment=ft.MainAxisAlignment.START),
ft.Divider(height=2, thickness=2)
], spacing=10),
padding=20,
bgcolor=ft.Colors.BLUE_50,
border_radius=10,
margin=ft.Margin.only(bottom=20)
)
# 操作説明
self.instructions = ft.Container(
content=ft.Column([
ft.Text(
"操作方法",
size=16,
weight=ft.FontWeight.BOLD,
color=ft.Colors.BLUE_900
),
ft.Text("• 左側のツリーから商品を選択して編集", size=12),
ft.Text("• カテゴリの展開/折りたたみ:▶/▼アイコンをクリック", size=12),
ft.Text("• 新規追加:選択中のノードの子として追加", size=12),
ft.Text("• PDFプレビュー階層構造をキャラクターベースで表示", size=12),
ft.Text("• 巨大カッコPDF出力時に階層を視覚的に表現", size=12),
], spacing=5),
padding=15,
bgcolor=ft.Colors.GREY_50,
border_radius=10,
margin=ft.Margin.only(bottom=20)
)
# メインコンテナ
self.main_container = ft.Column([
self.header,
self.instructions,
self.product_master.build()
], expand=True, spacing=20)
# ページに追加
page.add(
ft.Container(
content=self.main_container,
padding=20,
bgcolor=ft.Colors.GREY_100,
expand=True
)
)
logging.info("階層構造商品マスターアプリ起動完了")
print("🚀 階層構造商品マスターアプリ起動完了")
def main(page: ft.Page):
"""メイン関数"""
try:
app = HierarchicalProductMasterApp(page)
except Exception as e:
logging.error(f"アプリケーション起動エラー: {e}")
if __name__ == "__main__":
ft.run(main)