You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.3 KiB
85 lines
2.3 KiB
"""
|
|
Tesla Coil Spark Physics Course - Main Application Entry Point
|
|
PyQt5 Desktop Application
|
|
"""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Add parent directory to path so we can import app package
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
from PyQt5.QtWidgets import QApplication, QMessageBox
|
|
from PyQt5.QtCore import Qt
|
|
|
|
# Import configuration and models
|
|
from app import config
|
|
from app.database import get_database
|
|
from app.models import get_course
|
|
from app.views import MainWindow
|
|
|
|
|
|
def main():
|
|
"""Main application entry point"""
|
|
|
|
# Create QApplication
|
|
app = QApplication(sys.argv)
|
|
app.setApplicationName(config.APP_NAME)
|
|
app.setApplicationVersion(config.APP_VERSION)
|
|
app.setOrganizationName(config.APP_AUTHOR)
|
|
|
|
# Enable high DPI scaling
|
|
app.setAttribute(Qt.AA_EnableHighDpiScaling, True)
|
|
app.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
|
|
|
|
print("="*60)
|
|
print(f"{config.APP_NAME} v{config.APP_VERSION}")
|
|
print("="*60)
|
|
|
|
try:
|
|
# Initialize database
|
|
print("[*] Initializing database...")
|
|
db = get_database()
|
|
print(f"[OK] Database ready: {db.db_path}")
|
|
|
|
# Load course structure
|
|
print("[*] Loading course structure...")
|
|
course = get_course()
|
|
print(f"[OK] Course loaded: {course.title}")
|
|
|
|
# Validate lesson files
|
|
print("[*] Validating lesson files...")
|
|
if course.validate():
|
|
print("[OK] All lesson files found")
|
|
else:
|
|
print("[WARN] Some lesson files missing (see above)")
|
|
|
|
# Create and show main window
|
|
print("[*] Creating main window...")
|
|
window = MainWindow()
|
|
window.show()
|
|
|
|
print("[OK] Application ready!\n")
|
|
|
|
# Run application event loop
|
|
return app.exec_()
|
|
|
|
except Exception as e:
|
|
# Show error dialog
|
|
print(f"\n[ERROR] {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
|
|
error_dialog = QMessageBox()
|
|
error_dialog.setIcon(QMessageBox.Critical)
|
|
error_dialog.setWindowTitle("Error")
|
|
error_dialog.setText("Failed to initialize application")
|
|
error_dialog.setInformativeText(str(e))
|
|
error_dialog.setDetailedText(traceback.format_exc())
|
|
error_dialog.exec_()
|
|
|
|
return 1
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|