File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33"""
44
55# Import telegram_selector first using absolute import to ensure PyInstaller includes it
6+ # Try multiple import strategies to ensure PyInstaller detects it
67try :
78 from app .gui .widgets .telegram_selector import TelegramSelectorDialog
89except ImportError :
9- # Fallback for relative import if absolute fails
10- from .telegram_selector import TelegramSelectorDialog
10+ try :
11+ # Try relative import
12+ from .telegram_selector import TelegramSelectorDialog
13+ except ImportError :
14+ # Last resort: try importing the module directly
15+ import importlib
16+ import sys
17+ import os
18+ # Get the directory of this file
19+ widgets_dir = os .path .dirname (os .path .abspath (__file__ ))
20+ if widgets_dir not in sys .path :
21+ sys .path .insert (0 , widgets_dir )
22+ try :
23+ telegram_selector_module = importlib .import_module ('telegram_selector' )
24+ TelegramSelectorDialog = telegram_selector_module .TelegramSelectorDialog
25+ except ImportError :
26+ # If all else fails, create a dummy class to prevent complete failure
27+ class TelegramSelectorDialog :
28+ def __init__ (self , * args , ** kwargs ):
29+ raise RuntimeError ("TelegramSelectorDialog module not found. Please rebuild the executable with PyInstaller using main.spec" )
1130
1231from .account_widget import AccountWidget , AccountListWidget
1332from .campaign_widget import CampaignWidget , CampaignListWidget
Original file line number Diff line number Diff line change 1+ """
2+ Runtime hook to ensure telegram_selector module is available.
3+ This is executed before the main script runs.
4+ """
5+
6+ import sys
7+ import os
8+
9+ # Add the app directory to path if not already there
10+ if hasattr (sys , '_MEIPASS' ):
11+ # We're running from a PyInstaller bundle
12+ app_path = os .path .join (sys ._MEIPASS , 'app' )
13+ if app_path not in sys .path :
14+ sys .path .insert (0 , app_path )
15+
16+ # Try to import the module explicitly
17+ try :
18+ import app .gui .widgets .telegram_selector
19+ except ImportError :
20+ # If import fails, try to add the widgets directory
21+ widgets_path = os .path .join (sys ._MEIPASS , 'app' , 'gui' , 'widgets' )
22+ if widgets_path not in sys .path :
23+ sys .path .insert (0 , widgets_path )
24+ try :
25+ import telegram_selector
26+ # Make it available as app.gui.widgets.telegram_selector
27+ import app .gui .widgets as widgets_module
28+ widgets_module .telegram_selector = telegram_selector
29+ except ImportError :
30+ pass # Will fail at runtime if really needed
31+
You can’t perform that action at this time.
0 commit comments