S1005403_RisCC/target_simulator/__main__.py

58 lines
1.4 KiB
Python

# target_simulator/__main__.py
"""
Main entry point for the Target Simulator application.
This script initializes the logging system, creates the main application
window, and starts the Tkinter event loop.
"""
import sys
import os
# Add the project root to the Python path to allow absolute imports
project_root = os.path.dirname(os.path.abspath(__file__))
if project_root not in sys.path:
sys.path.insert(0, project_root)
from target_simulator.gui.main_view import MainView
from target_simulator.utils.logger import (
setup_basic_logging,
get_logger,
add_tkinter_handler,
apply_saved_logger_levels,
)
from target_simulator.config import LOGGING_CONFIG
def main():
"""Initializes and runs the application."""
import logging
logging.getLogger("matplotlib").setLevel(logging.WARNING)
app = MainView()
# Setup the global logging system, connecting it to the GUI's main loop
setup_basic_logging(app, LOGGING_CONFIG)
# Apply any saved logger levels so preferences take effect even if the
# LoggerPanel is never opened.
try:
apply_saved_logger_levels()
except Exception:
pass
# Now that the logging system is active, add the handler for the GUI widget
add_tkinter_handler(app.log_text_widget, LOGGING_CONFIG)
logger = get_logger(__name__)
logger.info("Application starting up.")
app.mainloop()
if __name__ == "__main__":
main()