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

69 lines
2.3 KiB
Python

# -*- coding: utf-8 -*-
"""
Main entry point script for the PyInstaller GUI Wrapper application when run as a module.
"""
import sys
import os
import traceback # Import traceback for better error reporting
# --- No sys.path manipulation needed when running as a module ---
# Python handles the package structure automatically.
# --- Import the necessary modules ---
try:
# MODIFIED: Use relative import to get the GUI class from within the same package
from .gui import PyInstallerGUI
except ImportError as e:
# Provide more context in case of import errors
package_dir = os.path.dirname(os.path.abspath(__file__))
print(f"ERROR: Could not import required modules from package.")
print(f" Attempted relative import within: {package_dir}")
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:
# MODIFIED: Error message context updated
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()
# MODIFIED: Messagebox content translated/updated
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 ---
# This guard is still useful if you were to potentially import `__main__` elsewhere,
# though it's less critical when the primary execution path is `python -m`.
if __name__ == "__main__":
# print(f"Running PyInstallerGUIWrapper via __main__.py with Python {sys.version}")
main()