SXXXXXXX_PyInstallerGUIWrapper/pyinstallerguiwrapper/CreateExecFromPy.py
2025-05-05 12:35:58 +02:00

76 lines
2.3 KiB
Python

# -*- coding: utf-8 -*-
"""
Main entry point script for the PyInstaller GUI Wrapper application.
This script imports the main GUI class and starts the Tkinter event loop.
Run this file to launch the application.
"""
import sys
import os
import traceback # Import traceback for better error reporting
# --- Crucial: Add the directory containing the modules to sys.path ---
# This allows Python to find 'gui.py', 'config.py', etc. when run directly.
script_dir = os.path.dirname(os.path.abspath(__file__))
print(f"Adding to sys.path: {script_dir}") # Debug print
if script_dir not in sys.path:
sys.path.insert(0, script_dir)
# --- Import the necessary modules ---
# Use direct imports now that the path is set
try:
# Import the main GUI class directly by name
from gui import PyInstallerGUI
# We might need other modules here later if needed at top level
# import config
# import builder
# import spec_parser
except ImportError as e:
print(f"ERROR: Could not import required modules.")
print(f"ImportError: {e}")
print(f"Current sys.path: {sys.path}")
traceback.print_exc() # Print detailed traceback
sys.exit(1)
except Exception as e:
print(f"ERROR: An unexpected error occurred during initial imports: {e}")
traceback.print_exc()
sys.exit(1)
def main():
"""
Initializes and runs the PyInstaller GUI application.
"""
try:
app = PyInstallerGUI()
app.mainloop()
except Exception as e:
print(
f"FATAL ERROR: An unexpected error occurred during application execution: {e}"
)
traceback.print_exc()
try:
# Attempt to show a Tkinter error box if possible
import tkinter as tk
from tkinter import messagebox
root = tk.Tk()
root.withdraw()
messagebox.showerror(
"Fatal Error",
f"Application failed to run:\n{e}\n\nSee console for details.",
)
root.destroy()
except Exception:
pass # Ignore if Tkinter fails here too
sys.exit(1)
# --- Main Execution Guard ---
if __name__ == "__main__":
# Check Python version if needed (Tkinter themes benefit from newer versions)
# print(f"Running with Python {sys.version}")
main()