-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
96 lines (74 loc) · 3.12 KB
/
Copy pathmain.py
File metadata and controls
96 lines (74 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
"""
ENSAM Traduction — Technical Document Translator
Entry point: creates Models, Views, and Controllers, then launches the app.
Powered by Groq API | Built with PyQt6 | MVC Architecture
"""
import sys
import os
import logging
# Ensure the project root and src directory are in the path
root_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, root_dir)
sys.path.insert(0, os.path.join(root_dir, "src"))
from PyQt6.QtWidgets import QApplication
from PyQt6.QtGui import QFont, QIcon
from PyQt6.QtCore import Qt
import ctypes
def setup_logging():
"""Configure application logging."""
log_dir = os.path.join(os.path.dirname(__file__), "data")
os.makedirs(log_dir, exist_ok=True)
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(name)s] %(levelname)s: %(message)s",
handlers=[
logging.FileHandler(os.path.join(log_dir, "linguist_tech.log"), encoding="utf-8"),
logging.StreamHandler(sys.stdout),
],
)
def main():
"""Launch the ENSAM Traduction application (MVC)."""
setup_logging()
logger = logging.getLogger("LinguistTech")
logger.info("=" * 60)
logger.info("ENSAM Traduction — Starting up (MVC Architecture)...")
logger.info("=" * 60)
# Windows taskbar icon fix
try:
myappid = 'ensam.traduction.app.2.0'
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
except Exception as e:
logger.warning(f"Could not set Windows AppUserModelID: {e}")
# ── Create Qt Application ─────────────────────────────────
app = QApplication(sys.argv)
app.setApplicationName("ENSAM Traduction")
app.setOrganizationName("ENSAM")
icon_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "LOGO.png")
app.setWindowIcon(QIcon(icon_path))
font = QFont("Segoe UI", 10)
app.setFont(font)
app.setHighDpiScaleFactorRoundingPolicy(
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough
)
# ── MVC Setup ─────────────────────────────────────────────
# Model: Translation pipeline (owns all business logic)
from models.pipeline import TranslationPipeline
pipeline = TranslationPipeline()
logger.info("Model layer initialized")
# View: Main application window (pure UI)
from views.main_view import MainView
view = MainView()
logger.info("View layer initialized")
# Controller: Wires Model ↔ View
from controllers.app_controller import AppController
controller = AppController(view, pipeline)
controller.initialize()
logger.info("Controller layer initialized")
# ── Show and Run ──────────────────────────────────────────
view.showMaximized()
logger.info("Application window displayed maximized")
exit_code = app.exec()
logger.info(f"Application exiting with code {exit_code}")
sys.exit(exit_code)
if __name__ == "__main__":
main()