Skip to content
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
9 changes: 6 additions & 3 deletions NodeGraphQt/base/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,10 @@ def _deserialize(self, data, relative_pos=False, pos=None, set_parent=True):
"""
if not self._editable:
return

_temp_auto_update = self._auto_update
self._auto_update = False

nodes = {}
# build the nodes.
for n_id, n_data in data.get('nodes', {}).items():
Expand Down Expand Up @@ -1269,6 +1273,7 @@ def _deserialize(self, data, relative_pos=False, pos=None, set_parent=True):

if set_parent:
[node.set_parent(self._current_node_space) for node in node_objs]
self._auto_update = _temp_auto_update

return node_objs

Expand Down Expand Up @@ -1340,8 +1345,7 @@ def import_session(self, file_path):
Args:
file_path (str): path to the serialized layout file.
"""
_temp_auto_update = self._auto_update
self._auto_update = False

file_path = file_path.strip()
if not os.path.isfile(file_path):
raise IOError('file does not exist.')
Expand All @@ -1368,7 +1372,6 @@ def import_session(self, file_path):
self.clear_undo_stack()
self._model.session = file_path
self.session_changed.emit(file_path)
self._auto_update = _temp_auto_update

def copy_nodes(self, nodes=None):
"""
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/base/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, node):
self.multi_connection = False
self.visible = True
self.connected_ports = defaultdict(list)
self.data_type = 'None'
self.data_type = 'NoneType'

def __repr__(self):
return '<{}(\'{}\') @ {}>'.format(
Expand Down
4 changes: 2 additions & 2 deletions NodeGraphQt/base/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ def add_checkbox(self, name, label='', text='', state=False, tab=None):
self.view.add_widget(widget)

def add_input(self, name='input', multi_input=False, display_name=True,
color=None, data_type='None', painter_func=None):
color=None, data_type='NoneType', painter_func=None):
"""
Add input :class:`Port` to node.

Expand Down Expand Up @@ -803,7 +803,7 @@ def add_input(self, name='input', multi_input=False, display_name=True,
return port

def add_output(self, name='output', multi_output=True, display_name=True,
color=None, data_type='None', painter_func=None):
color=None, data_type='NoneType', painter_func=None):
"""
Add output :class:`Port` to node.

Expand Down
12 changes: 8 additions & 4 deletions NodeGraphQt/base/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def setup_context_menu(graph):

edit_menu.add_separator()

edit_menu.add_command('Layout Graph Down Stream', _layout_graph_down, 'L')
edit_menu.add_command('Layout Graph Up Stream', _layout_graph_up, 'Ctrl+L')
edit_menu.add_command('Layout Graph Up Stream', _layout_graph_up, 'L')
edit_menu.add_command('Layout Graph Down Stream', _layout_graph_down, 'Ctrl+L')

edit_menu.add_separator()

Expand Down Expand Up @@ -826,10 +826,14 @@ def minimize_node_ref_count(node):
if hasattr(node, 'deleted'):
del node
return
from .node import BaseNode, SubGraph
from .node import BaseNode
from .graph import SubGraph
node._parent = None
if isinstance(node, BaseNode):
[wid.deleteLater() for wid in node.view._widgets.values()]
try:
[wid.deleteLater() for wid in node.view._widgets.values()]
except:
pass
node.view._widgets.clear()
for port in node._inputs:
port.model.node = None
Expand Down
2 changes: 0 additions & 2 deletions NodeGraphQt/qgraphics/pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,6 @@ def delete(self):
self.output_port.remove_pipe(self)
if self.scene():
self.scene().removeItem(self)
# TODO: not sure if we need this...?
del self


class LivePipe(Pipe):
Expand Down
5 changes: 2 additions & 3 deletions NodeGraphQt/widgets/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ def mousePressEvent(self, event):

items = self._items_near(map_pos, None, 20, 20)
nodes = [i for i in items if isinstance(i, AbstractNodeItem)]
pipes = [i for i in items if isinstance(i, Pipe)]

if nodes:
self.MMB_state = False
Expand Down Expand Up @@ -735,7 +734,7 @@ def tab_search_set_nodes(self, nodes):
self._search_widget.set_nodes(nodes)

def tab_search_toggle(self):
if type(self._search_widget) is TabSearchMenuWidget:
if isinstance(self._search_widget, TabSearchMenuWidget):
return

pos = self._previous_pos
Expand All @@ -753,7 +752,7 @@ def tab_search_toggle(self):
self.clearFocus()

def rebuild_tab_search(self):
if type(self._search_widget) is TabSearchMenuWidget:
if isinstance(self._search_widget, TabSearchMenuWidget):
self._search_widget.rebuild = True

def context_menus(self):
Expand Down
1 change: 1 addition & 0 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def __init__(self):


if __name__ == '__main__':
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
app = QtWidgets.QApplication([])

# create node graph.
Expand Down
1 change: 1 addition & 0 deletions example_auto_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def get_published_nodes_from_folder(folder_path):


if __name__ == '__main__':
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
app = QtWidgets.QApplication()

# create node graph.
Expand Down
4 changes: 2 additions & 2 deletions example_auto_nodes/data_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class VectorSplit(AutoNode):
"""
Splict a vector to x,y,z
Split a vector to x,y,z
"""

__identifier__ = 'Data'
Expand Down Expand Up @@ -49,7 +49,7 @@ def __init__(self):
super(VectorMaker, self).__init__()

self.add_output('out', list)
self.create_property("out",None)
self.create_property("out", None)

self.add_input("x", float)
self.add_input("y", float)
Expand Down
Loading