|
2 | 2 | Reusable GUI widgets for the application. |
3 | 3 | """ |
4 | 4 |
|
5 | | -# Lazy import function for TelegramSelectorDialog to avoid import errors at module level |
6 | | -# This allows PyInstaller to include the module even if it's not directly imported |
7 | | -def _get_telegram_selector_dialog(): |
8 | | - """Lazy import function for TelegramSelectorDialog.""" |
9 | | - try: |
10 | | - from app.gui.widgets.telegram_selector import TelegramSelectorDialog |
11 | | - return TelegramSelectorDialog |
12 | | - except ImportError: |
13 | | - try: |
14 | | - from .telegram_selector import TelegramSelectorDialog |
15 | | - return TelegramSelectorDialog |
16 | | - except ImportError: |
17 | | - import importlib |
18 | | - import sys |
19 | | - import os |
20 | | - # Get the directory of this file |
21 | | - widgets_dir = os.path.dirname(os.path.abspath(__file__)) |
22 | | - if widgets_dir not in sys.path: |
23 | | - sys.path.insert(0, widgets_dir) |
24 | | - try: |
25 | | - telegram_selector_module = importlib.import_module('telegram_selector') |
26 | | - return telegram_selector_module.TelegramSelectorDialog |
27 | | - except ImportError: |
28 | | - # If all else fails, create a dummy class |
29 | | - class TelegramSelectorDialog: |
30 | | - def __init__(self, *args, **kwargs): |
31 | | - raise RuntimeError("TelegramSelectorDialog module not found. Please rebuild the executable with PyInstaller using main.spec") |
32 | | - return TelegramSelectorDialog |
33 | | - |
34 | | -# Import it immediately to ensure PyInstaller sees it, but use the function for lazy loading |
35 | | -try: |
36 | | - from app.gui.widgets.telegram_selector import TelegramSelectorDialog |
37 | | -except ImportError: |
38 | | - # If import fails, use lazy loader |
39 | | - TelegramSelectorDialog = _get_telegram_selector_dialog() |
| 5 | +# Import telegram_selector FIRST using absolute import to ensure PyInstaller includes it |
| 6 | +# This MUST be at the top level, not in a try-except, so PyInstaller can detect it |
| 7 | +from app.gui.widgets.telegram_selector import TelegramSelectorDialog |
40 | 8 |
|
41 | 9 | from .account_widget import AccountWidget, AccountListWidget |
42 | 10 | from .campaign_widget import CampaignWidget, CampaignListWidget |
|
0 commit comments