-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_dpg_ui_compatibility.sh
More file actions
executable file
·114 lines (94 loc) · 3.8 KB
/
fix_dpg_ui_compatibility.sh
File metadata and controls
executable file
·114 lines (94 loc) · 3.8 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
#!/usr/bin/env bash
# Script to fix DearPyGui UI compatibility issues in OneTrainer
set -e
echo "=== Fixing DearPyGui UI compatibility issues ==="
# Function to check if DearPyGui is installed
check_dpg_installed() {
if python3 -c "import dearpygui" &>/dev/null; then
echo "✓ DearPyGui is installed"
python3 -c "import dearpygui; print(f' Version: {dearpygui.__version__}')"
return 0
else
echo "✗ DearPyGui is not installed"
echo "Please install DearPyGui with: pip install dearpygui"
return 1
fi
}
# Function to fix file_selector.py for DearPyGui 2.0
fix_file_selector() {
file_selector="dpg_ui/components/file_selector.py"
echo "Fixing file_selector.py for DearPyGui 2.0..."
if [ -f "$file_selector" ]; then
# Create a backup
cp "$file_selector" "${file_selector}.bak"
# Update the file directly with python
python3 -c "
with open('$file_selector', 'r') as f:
content = f.read()
# Replace the problematic section
old_section = ''' # Add extension filters if specified
if filter_ext:
ext_id = dpg.add_file_extension_info(parent=dialog_id)
for ext in filter_ext:
dpg.add_file_extension(extension=ext, parent=ext_id, custom_text=f\"*{ext} Files\")'''
new_section = ''' # Add extension filters if specified
if filter_ext:
# In DearPyGui 2.0.0, file extensions are added directly to the dialog
for ext in filter_ext:
# Use direct add_file_extension method
try:
dpg.add_file_extension(extension=ext, parent=dialog_id, custom_text=f\"*{ext} Files\")
except Exception as e:
print(f\"Warning: Could not add file extension {ext}: {e}\")'''
content = content.replace(old_section, new_section)
with open('$file_selector', 'w') as f:
f.write(content)
"
echo "✓ Fixed file_selector.py"
else
echo "✗ file_selector.py not found at expected location"
fi
}
# Function to fix switch component in basic.py
fix_basic_switch() {
basic_components="dpg_ui/components/basic.py"
echo "Fixing switch component in basic.py..."
if [ -f "$basic_components" ]; then
# Create a backup
cp "$basic_components" "${basic_components}.bak"
# Update the file directly with python
python3 -c "
with open('$basic_components', 'r') as f:
content = f.read()
# Replace the problematic section
old_section = ''' tag = tag or Components.generate_id(\"switch\")
dpg.add_checkbox(label=label, default_value=default_value,
callback=on_change, parent=parent, tag=tag, **kwargs)'''
new_section = ''' tag = tag or Components.generate_id(\"switch\")
# Make sure we don't pass callback if it's already in kwargs
if 'callback' not in kwargs:
dpg.add_checkbox(label=label, default_value=default_value,
callback=on_change, parent=parent, tag=tag, **kwargs)
else:
# Remove on_change if callback is provided in kwargs
dpg.add_checkbox(label=label, default_value=default_value,
parent=parent, tag=tag, **kwargs)'''
content = content.replace(old_section, new_section)
with open('$basic_components', 'w') as f:
f.write(content)
"
echo "✓ Fixed switch component in basic.py"
else
echo "✗ basic.py not found at expected location"
fi
}
# Main execution
echo "Checking for DearPyGui installation..."
check_dpg_installed
# Apply fixes
fix_file_selector
fix_basic_switch
echo ""
echo "=== All fixes applied ==="
echo "You can now run the DearPyGui UI with ./start-dpg-ui.sh"
echo ""