-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreplace_widgets.py
More file actions
104 lines (91 loc) · 2.76 KB
/
replace_widgets.py
File metadata and controls
104 lines (91 loc) · 2.76 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
"""
Bulk widget replacement script
Replaces standard Qt widgets with custom glassmorphic widgets
"""
import re
from pathlib import Path
# Files to process
files_to_process = [
"app/widgets/encoder_tab.py",
"app/widgets/subtitle_tab.py",
"app/widgets/metadata_tab.py",
]
# Replacement patterns
replacements = {
r'\bQLabel\(': 'StyledLabel(',
r'\bQCheckBox\(': 'StyledCheckBox(',
r'\bQComboBox\(': 'StyledComboBox(',
r'\bQLineEdit\(': 'StyledLineEdit(',
r'\bQSpinBox\(': 'StyledSpinBox(',
r'\bQTextEdit\(': 'StyledTextEdit(',
}
# Import additions needed
import_additions = {
"app/widgets/encoder_tab.py": [
"StyledCheckBox",
"StyledComboBox",
"StyledLabel",
"StyledLineEdit",
"StyledSpinBox",
],
"app/widgets/subtitle_tab.py": [
"GlassmorphicButton",
"GlassmorphicCard",
"StyledCheckBox",
"StyledComboBox",
"StyledLabel",
"StyledLineEdit",
"StyledSpinBox",
"StyledTextEdit",
],
"app/widgets/metadata_tab.py": [
"GlassmorphicButton",
"GlassmorphicCard",
"StyledCheckBox",
"StyledComboBox",
"StyledLabel",
"StyledLineEdit",
"StyledSpinBox",
"StyledTextEdit",
],
}
def process_file(filepath):
"""Process a single file"""
path = Path(filepath)
if not path.exists():
print(f"❌ File not found: {filepath}")
return
print(f"\n📝 Processing: {filepath}")
# Read file
content = path.read_text(encoding='utf-8')
original_content = content
# Apply replacements
changes_made = 0
for pattern, replacement in replacements.items():
matches = len(re.findall(pattern, content))
if matches > 0:
content = re.sub(pattern, replacement, content)
changes_made += matches
print(f" ✓ Replaced {matches} instances: {pattern} -> {replacement}")
if changes_made > 0:
# Write back
path.write_text(content, encoding='utf-8')
print(f" ✅ Saved {changes_made} changes to {filepath}")
else:
print(f" ℹ️ No changes needed")
def main():
"""Main execution"""
print("=" * 70)
print("ENCODEFORGE WIDGET REPLACEMENT SCRIPT")
print("=" * 70)
for filepath in files_to_process:
process_file(filepath)
print("\n" + "=" * 70)
print("✅ REPLACEMENT COMPLETE")
print("=" * 70)
print("\n⚠️ NEXT STEPS:")
print("1. Update imports in each file manually")
print("2. Test the application: py main.py")
print("3. Fix any remaining styling issues")
if __name__ == "__main__":
main()