import tkinter as tk import logging import sys # Import the necessary components from our application from downloaderyoutube.gui.gui import App from downloaderyoutube.utils.logger import setup_basic_logging, shutdown_logging_system # --- Logging Configuration --- LOGGING_CONFIG = { "default_root_level": logging.DEBUG, "specific_levels": {}, "format": "%(asctime)s [%(levelname)-8s] %(name)-25s : %(message)s", "date_format": "%Y-%m-%d %H:%M:%S", "enable_console": True, "enable_file": False, } def main(): """ Application entry point. Initializes logging, creates the GUI, and starts the main loop. """ root = tk.Tk() # --- Setup Logging --- setup_basic_logging( root_tk_instance_for_processor=root, logging_config_dict=LOGGING_CONFIG ) logger = logging.getLogger(__name__) logger.info("Application starting...") # --- Create and run the App --- app = App(master=root) def on_closing(): """ Handles the window closing event to ensure a clean shutdown. """ logger.info("Shutdown sequence initiated.") app.save_last_path() # Save the path before closing shutdown_logging_system() root.destroy() # Assign the custom closing function to the window's close button root.protocol("WM_DELETE_WINDOW", on_closing) # Start the Tkinter event loop root.mainloop() print("Application has been closed.") if __name__ == "__main__": main()