#!/usr/bin/env python

import sys
import os
from pathlib import Path

# Add the project paths
_current_dir = os.path.dirname(os.path.abspath(__file__))
_project_root = os.path.dirname(os.path.dirname(os.path.dirname(_current_dir)))
sys.path.insert(0, _project_root)
sys.path.insert(0, _current_dir)

print("Testing imports...")
try:
    from PyQt6.QtWidgets import QApplication
    from PyQt6.QtCore import Qt
    from PyQt6.QtGui import QMovie
    from PyQt6.uic import loadUi
    print("[OK] PyQt6 imports successful")
except ImportError as e:
    print(f"[ERROR] PyQt6 import error: {e}")
    sys.exit(1)

print("Testing UI file path...")
script_yolu = str(Path(__file__).parent)
ui_path = os.path.join(script_yolu, "formAna.ui")
print(f"UI path: {ui_path}")
print(f"UI file exists: {os.path.exists(ui_path)}")

if os.path.exists(ui_path):
    print("Testing UI loading...")
    try:
        app = QApplication(sys.argv)
        ui = loadUi(ui_path, None)
        print("[OK] UI file loaded successfully")

        # Test if the new widgets exist
        if hasattr(ui, 'comboMalzeme'):
            print("[OK] comboMalzeme widget found")
        else:
            print("[ERROR] comboMalzeme widget not found")

        if hasattr(ui, 'spinYoğunluk'):
            print("[OK] spinYoğunluk widget found")
        else:
            print("[ERROR] spinYoğunluk widget not found")

        if hasattr(ui, 'btnEksenSec'):
            print("[OK] btnEksenSec widget found")
        else:
            print("[ERROR] btnEksenSec widget not found")

        if hasattr(ui, 'btnBodySec'):
            print("[OK] btnBodySec widget found")
        else:
            print("[ERROR] btnBodySec widget not found")

    except Exception as e:
        print(f"[ERROR] UI loading error: {e}")
        import traceback
        traceback.print_exc()
else:
    print("[ERROR] UI file not found")

print("Test completed.")