-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-dpg-ui-fixed.py
More file actions
executable file
·124 lines (108 loc) · 4.13 KB
/
start-dpg-ui-fixed.py
File metadata and controls
executable file
·124 lines (108 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env python3
"""
DPG UI Launcher for OneTrainer
Fixed version with comprehensive error handling and safer component usage.
"""
import os
import sys
import traceback
import importlib.util
import time
from pathlib import Path
# Add the project root to the path
current_dir = os.path.dirname(os.path.abspath(__file__))
if current_dir not in sys.path:
sys.path.insert(0, current_dir)
# Banner
print("""
╔═════════════════════════════════════════════╗
║ OneTrainer DPG UI Launcher ║
║ (Fixed version with enhanced error handling) ║
╚═════════════════════════════════════════════╝
""")
# Check for required modules
required_modules = {
"dearpygui": "DPG UI requires Dear PyGui. Install with: pip install dearpygui",
"torch": "OneTrainer requires PyTorch. Install with: pip install torch",
}
missing_modules = []
for module_name, message in required_modules.items():
try:
importlib.import_module(module_name)
print(f"✓ {module_name} is available")
except ImportError:
missing_modules.append((module_name, message))
if missing_modules:
print("\nMissing required modules:")
for module_name, message in missing_modules:
print(f" ✗ {module_name}: {message}")
sys.exit(1)
# Import necessary modules for the UI
try:
import dearpygui.dearpygui as dpg
# Ensure component extensions are loaded
from dpg_ui.components import Components
# Test if file_selector is available
print("✓ UI components initialized, checking for file_selector...")
if not hasattr(Components, 'file_selector'):
print("ERROR: file_selector component is not available.")
print("Using emergency fallback to ensure it exists...")
from dpg_ui.components.extensions import extend_components
extend_components(Components)
if hasattr(Components, 'file_selector'):
print("✓ Successfully added file_selector component")
else:
print("✗ Failed to add file_selector, will likely encounter errors")
else:
print("✓ file_selector component is available")
except Exception as e:
print(f"Error setting up required components: {e}")
traceback.print_exc()
sys.exit(1)
def run_app():
"""Run the application with error handling"""
try:
# Try to import and run the enhanced app
print("Starting enhanced DPG UI with full LyCORIS support...")
try:
from dpg_ui.app_enhanced import OneTrainerApp
app = OneTrainerApp()
app.run()
return True
except Exception as e:
print(f"Error with enhanced UI: {e}")
traceback.print_exc()
# Fall back to standard app
print("\nTrying standard DPG UI...")
try:
from dpg_ui.app import OneTrainerApp as StandardApp
app = StandardApp()
app.run()
return True
except Exception as e2:
print(f"Error with standard UI: {e2}")
traceback.print_exc()
# Last resort - try the onetrainer_dpg_full implementation
print("\nTrying basic DPG implementation...")
try:
from onetrainer_dpg_full import OneTrainerDPG
app = OneTrainerDPG()
app.run()
return True
except Exception as e3:
print(f"Error with basic implementation: {e3}")
traceback.print_exc()
return False
finally:
# Always clean up DPG
try:
dpg.destroy_context()
except:
pass
if __name__ == "__main__":
success = run_app()
if not success:
print("\n❌ Failed to start any UI implementation.")
print("Check the error messages above for details.")
# Small delay to ensure messages are visible
time.sleep(1)