Skip to content

Commit 9131429

Browse files
authored
Merge pull request #158 from ArnoChenFx/master
import with relative path
2 parents ec2a602 + 014c1ad commit 9131429

26 files changed

+299
-266
lines changed

NodeGraphQt/base/commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/python
2-
from NodeGraphQt import QtWidgets
2+
from .. import QtWidgets
33

4-
from NodeGraphQt.constants import IN_PORT, OUT_PORT
4+
from ..constants import IN_PORT, OUT_PORT
55

66

77
class PropertyChangedCmd(QtWidgets.QUndoCommand):

NodeGraphQt/base/factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/python
22

3-
from NodeGraphQt.errors import NodeRegistrationError
3+
from ..errors import NodeRegistrationError
44

55

66
class NodeFactory(object):

NodeGraphQt/base/graph.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@
55
import re
66
import copy
77

8-
from NodeGraphQt import QtCore, QtWidgets, QtGui
9-
from NodeGraphQt.base.commands import (NodeAddedCmd,
10-
NodeRemovedCmd,
11-
NodeMovedCmd,
12-
PortConnectedCmd)
13-
from NodeGraphQt.base.factory import NodeFactory
14-
from NodeGraphQt.base.menu import NodeGraphMenu, NodesMenu
15-
from NodeGraphQt.base.model import NodeGraphModel
16-
from NodeGraphQt.base.node import NodeObject, BaseNode
17-
from NodeGraphQt.base.port import Port
18-
from NodeGraphQt.constants import (DRAG_DROP_ID,
19-
PIPE_LAYOUT_CURVED,
20-
PIPE_LAYOUT_STRAIGHT,
21-
PIPE_LAYOUT_ANGLE,
22-
IN_PORT, OUT_PORT)
23-
from NodeGraphQt.widgets.viewer import NodeViewer
8+
from .. import QtCore, QtWidgets, QtGui
9+
from .commands import (NodeAddedCmd,
10+
NodeRemovedCmd,
11+
NodeMovedCmd,
12+
PortConnectedCmd)
13+
from .factory import NodeFactory
14+
from .menu import NodeGraphMenu, NodesMenu
15+
from .model import NodeGraphModel
16+
from .node import NodeObject, BaseNode
17+
from .port import Port
18+
from ..constants import (DRAG_DROP_ID,
19+
PIPE_LAYOUT_CURVED,
20+
PIPE_LAYOUT_STRAIGHT,
21+
PIPE_LAYOUT_ANGLE,
22+
IN_PORT, OUT_PORT)
23+
from ..widgets.viewer import NodeViewer
2424

2525

2626
class QWidgetDrops(QtWidgets.QWidget):
@@ -43,7 +43,7 @@ def dropEvent(self, event):
4343
for url in event.mimeData().urls():
4444
self.import_session(url.toLocalFile())
4545
else:
46-
e.ignore()
46+
event.ignore()
4747

4848

4949
class NodeGraph(QtCore.QObject):
@@ -119,6 +119,7 @@ class NodeGraph(QtCore.QObject):
119119
:parameters: :str
120120
:emits: new session path
121121
"""
122+
122123
def __init__(self, parent=None):
123124
super(NodeGraph, self).__init__(parent)
124125
self.setObjectName('NodeGraphQt')
@@ -204,7 +205,7 @@ def _on_property_bin_changed(self, node_id, prop_name, prop_value):
204205
node = self.get_node_by_id(node_id)
205206

206207
# prevent signals from causing a infinite loop.
207-
_exc = [float, int , str, bool, None]
208+
_exc = [float, int, str, bool, None]
208209
if node.get_property(prop_name) != prop_value:
209210
if type(node.get_property(prop_name)) in _exc:
210211
value = prop_value
@@ -351,8 +352,8 @@ def widget(self):
351352
if self._widget is None:
352353
self._widget = QWidgetDrops()
353354
self._widget.import_session = self.import_session
354-
355-
layout = QtWidgets.QVBoxLayout(self._widget)
355+
356+
layout = QtWidgets.QVBoxLayout(self._widget)
356357
layout.setContentsMargins(0, 0, 0, 0)
357358
layout.addWidget(self._viewer)
358359
return self._widget
@@ -1087,7 +1088,7 @@ def import_session(self, file_path):
10871088
Args:
10881089
file_path (str): path to the serialized layout file.
10891090
"""
1090-
1091+
10911092
file_path = file_path.strip()
10921093
if not os.path.isfile(file_path):
10931094
raise IOError('file does not exist.')

NodeGraphQt/base/menu.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/python
22
from distutils.version import LooseVersion
33

4-
from NodeGraphQt import QtGui, QtCore
5-
from NodeGraphQt.errors import NodeMenuError
6-
from NodeGraphQt.widgets.actions import BaseMenu, GraphAction, NodeAction
4+
from .. import QtGui, QtCore
5+
from ..errors import NodeMenuError
6+
from ..widgets.actions import BaseMenu, GraphAction, NodeAction
77

88

99
class NodeGraphMenu(object):

NodeGraphQt/base/model.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import json
33
from collections import defaultdict
44

5-
from NodeGraphQt.constants import (NODE_PROP,
6-
NODE_PROP_QLABEL,
7-
NODE_PROP_QLINEEDIT,
8-
NODE_PROP_QCHECKBOX,
9-
NODE_PROP_COLORPICKER)
10-
from NodeGraphQt.errors import NodePropertyError
5+
from ..constants import (NODE_PROP,
6+
NODE_PROP_QLABEL,
7+
NODE_PROP_QLINEEDIT,
8+
NODE_PROP_QCHECKBOX,
9+
NODE_PROP_COLORPICKER)
10+
from ..errors import NodePropertyError
1111

1212

1313
class PortModel(object):

NodeGraphQt/base/node.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
#!/usr/bin/python
2-
from NodeGraphQt.base.commands import PropertyChangedCmd
3-
from NodeGraphQt.base.model import NodeModel
4-
from NodeGraphQt.base.port import Port
5-
from NodeGraphQt.constants import (NODE_PROP,
6-
NODE_PROP_QLINEEDIT,
7-
NODE_PROP_QTEXTEDIT,
8-
NODE_PROP_QCOMBO,
9-
NODE_PROP_QCHECKBOX,
10-
NODE_PROP_FILE,
11-
NODE_PROP_FLOAT,
12-
NODE_PROP_INT,
13-
IN_PORT, OUT_PORT)
14-
from NodeGraphQt.errors import PortRegistrationError
15-
from NodeGraphQt.qgraphics.node_backdrop import BackdropNodeItem
16-
from NodeGraphQt.qgraphics.node_base import NodeItem
17-
from NodeGraphQt.widgets.node_widgets import (NodeComboBox,
18-
NodeLineEdit,
19-
NodeFloatEdit,
20-
NodeIntEdit,
21-
NodeCheckBox,
22-
NodeFilePath)
2+
from .commands import PropertyChangedCmd
3+
from .model import NodeModel
4+
from .port import Port
5+
from ..constants import (NODE_PROP,
6+
NODE_PROP_QLINEEDIT,
7+
NODE_PROP_QTEXTEDIT,
8+
NODE_PROP_QCOMBO,
9+
NODE_PROP_QCHECKBOX,
10+
NODE_PROP_FILE,
11+
NODE_PROP_FLOAT,
12+
NODE_PROP_INT,
13+
IN_PORT, OUT_PORT)
14+
from ..errors import PortRegistrationError
15+
from ..qgraphics.node_backdrop import BackdropNodeItem
16+
from ..qgraphics.node_base import NodeItem
17+
from ..widgets.node_widgets import (NodeComboBox,
18+
NodeLineEdit,
19+
NodeFloatEdit,
20+
NodeIntEdit,
21+
NodeCheckBox,
22+
NodeFilePath)
2323

2424

2525
class classproperty(object):
@@ -709,7 +709,7 @@ def update_combo_menu(self, name, items):
709709
return
710710
old_value = self.get_property(name)
711711
self.set_property(name, items)
712-
_name = '_'+name+"_"
712+
_name = '_' + name + "_"
713713
if not self.has_property(_name):
714714
self.create_property(_name, items)
715715
else:

NodeGraphQt/base/port.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/python
2-
from NodeGraphQt.base.commands import (PortConnectedCmd,
3-
PortDisconnectedCmd,
4-
PortVisibleCmd,
5-
NodeInputConnectedCmd,
6-
NodeInputDisconnectedCmd)
7-
from NodeGraphQt.base.model import PortModel
8-
from NodeGraphQt.constants import IN_PORT, OUT_PORT
2+
from .commands import (PortConnectedCmd,
3+
PortDisconnectedCmd,
4+
PortVisibleCmd,
5+
NodeInputConnectedCmd,
6+
NodeInputDisconnectedCmd)
7+
from .model import PortModel
8+
from ..constants import IN_PORT, OUT_PORT
99

1010

1111
class Port(object):

NodeGraphQt/base/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/python
22
from distutils.version import LooseVersion
33

4-
from NodeGraphQt import QtGui, QtCore
4+
from .. import QtGui, QtCore
55

66

77
def setup_context_menu(graph):

NodeGraphQt/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf-8 -*-
33
import os
44
from .pkg_info import __version__
5-
from NodeGraphQt import QtWidgets
5+
from . import QtWidgets
66

77
#: Current version of the NodeGraphQt framework.
88
VERSION = __version__

NodeGraphQt/errors.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
3+
4+
35
class NodeMenuError(Exception): pass
6+
7+
48
class NodePropertyError(Exception): pass
9+
10+
511
class NodeWidgetError(Exception): pass
12+
13+
614
class NodeRegistrationError(Exception): pass
15+
16+
717
class PortRegistrationError(Exception): pass

0 commit comments

Comments
 (0)