Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NodeGraphQt/base/commands.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtWidgets
from qtpy import QtWidgets

from NodeGraphQt.constants import PortTypeEnum

Expand Down
11 changes: 8 additions & 3 deletions NodeGraphQt/base/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import re
from pathlib import Path

from Qt import QtCore, QtWidgets
from qtpy import QtCore, QtWidgets

from NodeGraphQt.base.commands import (NodeAddedCmd,
NodesRemovedCmd,
Expand Down Expand Up @@ -35,6 +35,11 @@
from NodeGraphQt.widgets.viewer import NodeViewer
from NodeGraphQt.widgets.viewer_nav import NodeNavigationWidget

import qtpy
if qtpy.API_NAME in ("PyQt5", "PySide2"):
from qtpy.QtWidgets import QUndoStack
elif qtpy.API_NAME in ("PyQt6", "PySide6"):
from qtpy.QtGui import QUndoStack

class NodeGraph(QtCore.QObject):
"""
Expand Down Expand Up @@ -151,7 +156,7 @@ def __init__(self, parent=None, **kwargs):
kwargs.get('node_factory') or NodeFactory())
self._undo_view = None
self._undo_stack = (
kwargs.get('undo_stack') or QtWidgets.QUndoStack(self)
kwargs.get('undo_stack') or QUndoStack(self)
)
self._widget = None
self._sub_graphs = {}
Expand Down Expand Up @@ -695,7 +700,7 @@ def undo_stack(self):
:meth:`NodeGraph.end_undo()`

Returns:
QtWidgets.QUndoStack: undo stack.
QUndoStack: undo stack.
"""
return self._undo_stack

Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/base/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
from distutils.version import LooseVersion

from Qt import QtGui, QtCore
from qtpy import QtGui, QtCore

from NodeGraphQt.errors import NodeMenuError
from NodeGraphQt.widgets.actions import BaseMenu, GraphAction, NodeAction
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
import os

from Qt import QtWidgets
from qtpy import QtWidgets
from enum import Enum

from .pkg_info import __version__ as _v
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/custom_widgets/nodes_palette.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
from collections import defaultdict

from Qt import QtWidgets, QtCore, QtGui
from qtpy import QtWidgets, QtCore, QtGui

from NodeGraphQt.constants import MIME_TYPE, URN_SCHEME

Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/custom_widgets/nodes_tree.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from Qt import QtWidgets, QtCore, QtGui
from qtpy import QtWidgets, QtCore, QtGui

from NodeGraphQt.constants import MIME_TYPE, URN_SCHEME

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtWidgets, QtCore, QtGui
from qtpy import QtWidgets, QtCore, QtGui

from .custom_widget_vectors import PropVector3, PropVector4
from .prop_widgets_abstract import BaseProperty
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtWidgets, QtCore
from qtpy import QtWidgets, QtCore

from NodeGraphQt.widgets.dialogs import FileDialog
from .prop_widgets_abstract import BaseProperty
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtWidgets, QtCore
from qtpy import QtWidgets, QtCore

from .prop_widgets_abstract import BaseProperty

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
import re

from Qt import QtWidgets, QtCore, QtGui
from qtpy import QtWidgets, QtCore, QtGui

_NUMB_REGEX = re.compile(r'^((?:\-)*\d+)*([\.,])*(\d+(?:[eE](?:[\-\+])*\d+)*)*')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtWidgets
from qtpy import QtWidgets

from .custom_widget_value_edit import _NumberValueEdit
from .prop_widgets_abstract import BaseProperty
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
from collections import defaultdict

from Qt import QtWidgets, QtCore, QtGui, QtCompat
from qtpy import QtWidgets, QtCore, QtGui

from .node_property_factory import NodePropertyWidgetFactory
from .prop_widgets_base import PropLineEdit
Expand Down Expand Up @@ -54,10 +54,10 @@ def __init__(self, parent=None):
self.verticalHeader().hide()
self.horizontalHeader().hide()

QtCompat.QHeaderView.setSectionResizeMode(
QtWidgets.QHeaderView.setSectionResizeMode(
self.verticalHeader(), QtWidgets.QHeaderView.ResizeToContents
)
QtCompat.QHeaderView.setSectionResizeMode(
QtWidgets.QHeaderView.setSectionResizeMode(
self.horizontalHeader(), 0, QtWidgets.QHeaderView.Stretch
)
self.setVerticalScrollMode(QtWidgets.QAbstractItemView.ScrollPerPixel)
Expand Down Expand Up @@ -218,7 +218,7 @@ def _build_tree_group(title):
tree_widget.setHeaderLabels(headers)
tree_widget.setHeaderHidden(False)
tree_widget.header().setStretchLastSection(False)
QtCompat.QHeaderView.setSectionResizeMode(
QtWidgets.QHeaderView.setSectionResizeMode(
tree_widget.header(), 2, QtWidgets.QHeaderView.Stretch
)

Expand Down Expand Up @@ -688,7 +688,7 @@ def __on_port_tree_visible_changed(self, node_id, visible, tree_widget):
tree_widget.setVisible(visible)
widget = self._prop_list.cellWidget(items[0].row(), 0)
widget.adjustSize()
QtCompat.QHeaderView.setSectionResizeMode(
QtWidgets.QHeaderView.setSectionResizeMode(
self._prop_list.verticalHeader(),
QtWidgets.QHeaderView.ResizeToContents
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtWidgets, QtCore
from qtpy import QtWidgets, QtCore


class BaseProperty(QtWidgets.QWidget):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtWidgets, QtCore
from qtpy import QtWidgets, QtCore


class PropLabel(QtWidgets.QLabel):
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/qgraphics/node_abstract.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtCore, QtWidgets
from qtpy import QtCore, QtWidgets

from NodeGraphQt.constants import (
Z_VAL_NODE,
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/qgraphics/node_backdrop.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtGui, QtCore, QtWidgets
from qtpy import QtGui, QtCore, QtWidgets

from NodeGraphQt.constants import Z_VAL_BACKDROP, NodeEnum
from NodeGraphQt.qgraphics.node_abstract import AbstractNodeItem
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/qgraphics/node_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
from collections import OrderedDict

from Qt import QtGui, QtCore, QtWidgets
from qtpy import QtGui, QtCore, QtWidgets

from NodeGraphQt.constants import (
ITEM_CACHE_MODE,
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/qgraphics/node_circle.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtCore, QtGui, QtWidgets
from qtpy import QtCore, QtGui, QtWidgets

from NodeGraphQt.constants import NodeEnum, PortEnum
from NodeGraphQt.qgraphics.node_base import NodeItem
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/qgraphics/node_group.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtCore, QtGui, QtWidgets
from qtpy import QtCore, QtGui, QtWidgets

from NodeGraphQt.constants import NodeEnum, PortEnum
from NodeGraphQt.qgraphics.node_base import NodeItem
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/qgraphics/node_overlay_disabled.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtGui, QtCore, QtWidgets
from qtpy import QtGui, QtCore, QtWidgets

from NodeGraphQt.constants import Z_VAL_NODE_WIDGET

Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/qgraphics/node_port_in.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtCore, QtGui, QtWidgets
from qtpy import QtCore, QtGui, QtWidgets

from NodeGraphQt.constants import NodeEnum
from NodeGraphQt.qgraphics.node_base import NodeItem
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/qgraphics/node_port_out.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtCore, QtGui, QtWidgets
from qtpy import QtCore, QtGui, QtWidgets

from NodeGraphQt.constants import NodeEnum
from NodeGraphQt.qgraphics.node_base import NodeItem
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/qgraphics/node_text_item.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from Qt import QtWidgets, QtCore, QtGui
from qtpy import QtWidgets, QtCore, QtGui


class NodeTextItem(QtWidgets.QGraphicsTextItem):
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/qgraphics/pipe.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
import math

from Qt import QtCore, QtGui, QtWidgets
from qtpy import QtCore, QtGui, QtWidgets

from NodeGraphQt.constants import (
LayoutDirectionEnum,
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/qgraphics/port.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtGui, QtCore, QtWidgets
from qtpy import QtGui, QtCore, QtWidgets

from NodeGraphQt.constants import (
PortTypeEnum, PortEnum,
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/qgraphics/slicer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
import math

from Qt import QtCore, QtGui, QtWidgets
from qtpy import QtCore, QtGui, QtWidgets

from NodeGraphQt.constants import Z_VAL_NODE_WIDGET, PipeSlicerEnum

Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/widgets/actions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtCore, QtWidgets
from qtpy import QtCore, QtWidgets

from NodeGraphQt.constants import ViewerEnum

Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/widgets/dialogs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from Qt import QtWidgets, QtGui, QtCore
from qtpy import QtWidgets, QtGui, QtCore

_current_user_directory = os.path.expanduser('~')

Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/widgets/node_graph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from Qt import QtWidgets, QtGui
from qtpy import QtWidgets, QtGui

from NodeGraphQt.constants import (
NodeEnum, ViewerEnum, ViewerNavEnum
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/widgets/node_widgets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtCore, QtWidgets
from qtpy import QtCore, QtWidgets

from NodeGraphQt.constants import ViewerEnum, Z_VAL_NODE_WIDGET
from NodeGraphQt.errors import NodeWidgetError
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/widgets/scene.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtGui, QtCore, QtWidgets
from qtpy import QtGui, QtCore, QtWidgets

from NodeGraphQt.constants import ViewerEnum

Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/widgets/tab_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
from collections import OrderedDict

from Qt import QtCore, QtWidgets, QtGui
from qtpy import QtCore, QtWidgets, QtGui

from NodeGraphQt.constants import ViewerEnum, ViewerNavEnum

Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/widgets/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import math
from distutils.version import LooseVersion

from Qt import QtGui, QtCore, QtWidgets
from qtpy import QtGui, QtCore, QtWidgets

from NodeGraphQt.base.menu import BaseMenu
from NodeGraphQt.constants import (
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/widgets/viewer_nav.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from Qt import QtWidgets, QtCore, QtGui
from qtpy import QtWidgets, QtCore, QtGui

from NodeGraphQt.constants import NodeEnum, ViewerNavEnum

Expand Down
1 change: 1 addition & 0 deletions NodeGraphQtPy
2 changes: 1 addition & 1 deletion examples/basic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import signal
from pathlib import Path

from Qt import QtCore, QtWidgets
from qtpy import QtCore, QtWidgets

from NodeGraphQt import (
NodeGraph,
Expand Down
2 changes: 1 addition & 1 deletion examples/hotkeys/hotkey_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def quit_qt(graph):
"""
Quit the Qt application.
"""
from Qt import QtCore
from qtpy import QtCore
QtCore.QCoreApplication.quit()

def clear_undo(graph):
Expand Down
2 changes: 1 addition & 1 deletion examples/nodes/custom_ports_node.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from Qt import QtCore, QtGui
from qtpy import QtCore, QtGui

from NodeGraphQt import BaseNode

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Qt.py>=1.3.0
QtPy==2.4.1
29 changes: 29 additions & 0 deletions utils/convert_to_qtpy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python

"""Script converts Qt import to qtpy.

"""
import fnmatch
import os
import re
import sys

PYTHON_SCRIPT_PATH = sys.argv[1]

if os.path.isdir(PYTHON_SCRIPT_PATH):
pattern = re.compile(r"^(from Qt) (.*)$")
for root, dirs, files in os.walk(PYTHON_SCRIPT_PATH):
for filename in files:
if fnmatch.fnmatch(filename, "*.py"):
filepath = os.path.join(root, filename)
filedata = []
with open(filepath) as f:
for line in f.readlines():
match = pattern.match(line)
if match is not None:
line = f"from qtpy {match.group(2)}"
filedata.append(line.strip("\n"))
with open(filepath, "w") as f:
f.write("\n".join(filedata))
else:
print("Argument is not a directory")