64 lines
2.7 KiB
Python
64 lines
2.7 KiB
Python
# LauncherTool/__main__.py
|
|
"""
|
|
Main entry point for the Grifo-E Launcher application.
|
|
Initializes and runs the Tkinter application.
|
|
"""
|
|
import tkinter as tk
|
|
import logging
|
|
import os
|
|
|
|
# Importa la classe principale dell'applicazione dalla GUI
|
|
# MODIFICA QUI: Cambia ApplicationManagerApp in MainWindow
|
|
from launchertool.gui.main_window import MainWindow
|
|
from launchertool.core.config_manager import ConfigManager
|
|
|
|
def main():
|
|
"""
|
|
Initializes and runs the application.
|
|
"""
|
|
logging.basicConfig(
|
|
level=logging.DEBUG,
|
|
format='%(asctime)s - %(levelname)s - %(module)s - %(funcName)s - %(message)s'
|
|
)
|
|
logging.info("Application starting...")
|
|
|
|
package_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
# Determina il path di config.json RELATIVO ALLA DIRECTORY DEL PACCHETTO LauncherTool
|
|
# Se config.json è DENTRO la cartella LauncherTool:
|
|
config_file_path = os.path.join(package_dir, "config.json")
|
|
|
|
# Se config.json è UN LIVELLO SOPRA la cartella LauncherTool (cioè nella root del progetto):
|
|
# project_root = os.path.dirname(package_dir)
|
|
# config_file_path = os.path.join(project_root, "config.json")
|
|
# Scegli una delle due opzioni per config_file_path a seconda di dove si trova il tuo config.json
|
|
|
|
# Assicurati che il file config.json sia nel path corretto.
|
|
# Per questo esempio, assumiamo che config.json sia nella stessa directory di __main__.py,
|
|
# cioè all'interno della cartella 'LauncherTool'.
|
|
if not os.path.exists(config_file_path):
|
|
# Se non è lì, prova un livello sopra (comune per i file di configurazione)
|
|
project_root_path = os.path.join(os.path.dirname(package_dir), "config.json")
|
|
if os.path.exists(project_root_path):
|
|
config_file_path = project_root_path
|
|
else:
|
|
# Se ancora non trovato, ConfigManager creerà un default, ma logghiamo un avviso
|
|
logging.warning(
|
|
f"config.json not found at {config_file_path} or {project_root_path}. "
|
|
"A default configuration will be created if possible."
|
|
)
|
|
# Non è necessario creare il file qui, ConfigManager lo gestisce
|
|
# Però, se si volesse forzare la sua creazione qui:
|
|
# with open(config_file_path, 'w') as f:
|
|
# json.dump({"applications": [], "sequences": []}, f, indent=2)
|
|
# logging.info(f"Created a default empty config.json at {config_file_path}")
|
|
|
|
|
|
# MODIFICA QUI: Cambia ApplicationManagerApp in MainWindow
|
|
app = MainWindow(config_file_path=config_file_path) # Non serve più istanziare tk.Tk() prima
|
|
app.run() # Chiama il metodo run() della MainWindow
|
|
|
|
logging.info("Application finished.")
|
|
|
|
if __name__ == "__main__":
|
|
main() |