Add patch for NodeGraphQt PySide6 6.7+ compatibility
The setSelectionArea() API changed in PySide6 6.7 - it now requires
an ItemSelectionOperation parameter before ItemSelectionMode.
Files added:
- patches/nodegraphqt_pyside6_compat.patch: Git-style patch file
- patches/UPSTREAM_ISSUE.md: Issue report for upstream project
- scripts/patch_nodegraphqt.py: Script to auto-apply the patch
The patch fixes rubber band selection errors when dragging in the
node graph viewer. Run after pip install:
python scripts/patch_nodegraphqt.py
Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Patch NodeGraphQt for PySide6 6.7+ compatibility.
|
||||
|
||||
The setSelectionArea() API changed in PySide6 6.7 to require an
|
||||
ItemSelectionOperation parameter. This script patches the installed
|
||||
NodeGraphQt package to work with newer PySide6 versions.
|
||||
|
||||
Issue: setSelectionArea(path, mode) -> setSelectionArea(path, operation, mode)
|
||||
|
||||
Usage:
|
||||
python scripts/patch_nodegraphqt.py
|
||||
|
||||
This can be run after `pip install NodeGraphQt-QuiltiX-fork[pyside6]`
|
||||
"""
|
||||
|
||||
import sys
|
||||
import site
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def find_viewer_file():
|
||||
"""Find the NodeGraphQt viewer.py file in site-packages."""
|
||||
# Check common locations
|
||||
for site_dir in site.getsitepackages() + [site.getusersitepackages()]:
|
||||
viewer_path = Path(site_dir) / "NodeGraphQt" / "widgets" / "viewer.py"
|
||||
if viewer_path.exists():
|
||||
return viewer_path
|
||||
|
||||
# Check virtual environment
|
||||
venv_path = Path(sys.prefix) / "lib"
|
||||
for python_dir in venv_path.glob("python*"):
|
||||
viewer_path = python_dir / "site-packages" / "NodeGraphQt" / "widgets" / "viewer.py"
|
||||
if viewer_path.exists():
|
||||
return viewer_path
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def patch_file(viewer_path: Path) -> bool:
|
||||
"""Apply the PySide6 compatibility patch."""
|
||||
content = viewer_path.read_text()
|
||||
|
||||
# Check if already patched
|
||||
if "Qt.ReplaceSelection" in content:
|
||||
print(f"Already patched: {viewer_path}")
|
||||
return True
|
||||
|
||||
# The old code pattern
|
||||
old_code = """self.scene().setSelectionArea(
|
||||
path, QtCore.Qt.IntersectsItemShape
|
||||
)"""
|
||||
|
||||
# The new code with ItemSelectionOperation
|
||||
new_code = """self.scene().setSelectionArea(
|
||||
path, QtCore.Qt.ReplaceSelection,
|
||||
QtCore.Qt.IntersectsItemShape
|
||||
)"""
|
||||
|
||||
if old_code not in content:
|
||||
print(f"Warning: Could not find code to patch in {viewer_path}")
|
||||
print("The file may have a different format or already be modified.")
|
||||
return False
|
||||
|
||||
# Apply patch
|
||||
patched_content = content.replace(old_code, new_code)
|
||||
|
||||
# Backup original
|
||||
backup_path = viewer_path.with_suffix(".py.bak")
|
||||
if not backup_path.exists():
|
||||
viewer_path.rename(backup_path)
|
||||
print(f"Backup created: {backup_path}")
|
||||
|
||||
# Write patched file
|
||||
viewer_path.write_text(patched_content)
|
||||
print(f"Patched successfully: {viewer_path}")
|
||||
return True
|
||||
|
||||
|
||||
def main():
|
||||
print("NodeGraphQt PySide6 Compatibility Patch")
|
||||
print("=" * 40)
|
||||
|
||||
viewer_path = find_viewer_file()
|
||||
|
||||
if not viewer_path:
|
||||
print("Error: Could not find NodeGraphQt installation.")
|
||||
print("Make sure NodeGraphQt-QuiltiX-fork is installed:")
|
||||
print(" pip install 'NodeGraphQt-QuiltiX-fork[pyside6]'")
|
||||
return 1
|
||||
|
||||
print(f"Found: {viewer_path}")
|
||||
|
||||
if patch_file(viewer_path):
|
||||
print("\nPatch applied successfully!")
|
||||
print("The rubber band selection should now work in PySide6 6.7+")
|
||||
return 0
|
||||
else:
|
||||
print("\nPatch failed.")
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user