Skip to content
Merged
2 changes: 1 addition & 1 deletion NodeGraphQt/base/actions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
from distutils.version import LooseVersion

from PySide2 import QtGui, QtCore
from ..vendor.Qt import QtGui, QtCore


def setup_context_menu(graph):
Expand Down
6 changes: 3 additions & 3 deletions NodeGraphQt/base/commands.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from PySide2.QtWidgets import QUndoCommand
from ..vendor.Qt.QtWidgets import QUndoCommand

from NodeGraphQt.constants import IN_PORT, OUT_PORT

Expand Down Expand Up @@ -259,9 +259,9 @@ def set_visible(self, visible):
self.port.view.setVisible(visible)
node_view = self.port.node().view
text_item = None
if self.port.type() == IN_PORT:
if self.port.type_() == IN_PORT:
text_item = node_view.get_input_text_item(self.port.view)
elif self.port.type() == OUT_PORT:
elif self.port.type_() == OUT_PORT:
text_item = node_view.get_output_text_item(self.port.view)
if text_item:
text_item.setVisible(visible)
Expand Down
20 changes: 10 additions & 10 deletions NodeGraphQt/base/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import os
import re

from PySide2 import QtCore
from PySide2.QtWidgets import QUndoStack, QAction, QApplication
from ..vendor.Qt import QtCore
from ..vendor.Qt.QtWidgets import QUndoStack, QAction, QApplication

from NodeGraphQt.base.commands import (NodeAddedCmd,
NodeRemovedCmd,
Expand Down Expand Up @@ -39,7 +39,7 @@ def __init__(self, parent=None, tab_search_key='tab'):
super(NodeGraph, self).__init__(parent)
self.setObjectName('NodeGraphQt')
self._model = NodeGraphModel()
self._viewer = NodeViewer()
self._viewer = NodeViewer(parent)
self._vendor = NodeVendor()
self._undo_stack = QUndoStack(self)

Expand Down Expand Up @@ -353,12 +353,12 @@ def create_node(self, node_type, name=None, selected=True, color=None, pos=None)
prop_attrs = node.model.__dict__.pop('_TEMP_property_attrs')

graph_attrs = self.model.node_property_attrs
if node.type not in graph_attrs.keys():
graph_attrs[node.type] = {
if node.type_ not in graph_attrs.keys():
graph_attrs[node.type_] = {
n: {'widget_type': wt} for n, wt in wid_types.items()
}
for pname, pattrs in prop_attrs.items():
graph_attrs[node.type][pname].update(pattrs)
graph_attrs[node.type_][pname].update(pattrs)

node.NODE_NAME = self.get_unique_name(name or node.NODE_NAME)
node.model.name = node.NODE_NAME
Expand Down Expand Up @@ -393,12 +393,12 @@ def add_node(self, node):
prop_attrs = node.model.__dict__.pop('_TEMP_property_attrs')

graph_attrs = self.model.node_property_attrs
if node.type not in graph_attrs.keys():
graph_attrs[node.type] = {
if node.type_ not in graph_attrs.keys():
graph_attrs[node.type_] = {
n: {'widget_type': wt} for n, wt in wid_types.items()
}
for pname, pattrs in prop_attrs.items():
graph_attrs[node.type][pname].update(pattrs)
graph_attrs[node.type_][pname].update(pattrs)

node._graph = self
node.NODE_NAME = self.get_unique_name(node.NODE_NAME)
Expand Down Expand Up @@ -603,7 +603,7 @@ def _deserialize(self, data, relative_pos=False, pos=None):

# build the nodes.
for n_id, n_data in data.get('nodes', {}).items():
identifier = n_data['type']
identifier = n_data['type_']
NodeCls = self._vendor.create_node_instance(identifier)
if NodeCls:
node = NodeCls()
Expand Down
6 changes: 3 additions & 3 deletions NodeGraphQt/base/menu.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
from distutils.version import LooseVersion

from PySide2 import QtGui, QtCore, QtWidgets
from ..vendor.Qt import QtGui, QtCore, QtWidgets

from NodeGraphQt.widgets.stylesheet import STYLE_QMENU

Expand Down Expand Up @@ -89,7 +89,7 @@ def add_menu(self, name):
Returns:
NodeGraphQt.Menu: the appended menu item.
"""
menu = QtWidgets.QMenu(None, title=name)
menu = QtWidgets.QMenu(name, self.qmenu)
menu.setStyleSheet(STYLE_QMENU)
self.qmenu.addMenu(menu)
return Menu(self.__viewer, menu)
Expand All @@ -113,7 +113,7 @@ def add_command(self, name, func=None, shortcut=None):
action.setShortcut(shortcut)
if func:
action.triggered.connect(func)
qaction = self.qmenu.addAction(action, shortcut=shortcut)
qaction = self.qmenu.addAction(action)
return MenuCommand(self.__viewer, qaction)

def add_separator(self):
Expand Down
14 changes: 7 additions & 7 deletions NodeGraphQt/base/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PortModel(object):

def __init__(self, node):
self.node = node
self.type = ''
self.type_ = ''
self.name = 'port'
self.display_name = True
self.multi_connection = False
Expand Down Expand Up @@ -46,7 +46,7 @@ def to_dict(self):
class NodeModel(object):

def __init__(self):
self.type = None
self.type_ = None
self.id = hex(id(self))
self.icon = None
self.name = 'node'
Expand All @@ -71,7 +71,7 @@ def __init__(self):
# temp store the property widget types.
# (deleted when node is added to the graph)
self._TEMP_property_widget_types = {
'type': NODE_PROP,
'type_': NODE_PROP,
'id': NODE_PROP,
'icon': NODE_PROP,
'name': NODE_PROP_QLINEEDIT,
Expand Down Expand Up @@ -113,11 +113,11 @@ def add_property(self, name, value, items=None, range=None, widget_type=NODE_PRO
if range:
self._TEMP_property_attrs[name]['range'] = range
else:
attrs = {self.type: {name: {'widget_type': widget_type}}}
attrs = {self.type_: {name: {'widget_type': widget_type}}}
if items:
attrs[self.type][name]['items'] = items
attrs[self.type_][name]['items'] = items
if range:
attrs[self.type][name]['range'] = range
attrs[self.type_][name]['range'] = range
self._graph_model.node_property_attrs.update(attrs)

def set_property(self, name, value):
Expand All @@ -137,7 +137,7 @@ def get_widget_type(self, name):
graph = self._graph_model
if graph is None:
return self._TEMP_property_widget_types.get(name)
return graph.node_property_attrs[self.type][name]['widget_type']
return graph.node_property_attrs[self.type_][name]['widget_type']

@property
def properties(self):
Expand Down
14 changes: 7 additions & 7 deletions NodeGraphQt/base/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ def __init__(self, node=None):
assert node, 'node cannot be None.'
self._graph = None
self._model = NodeModel()
self._model.type = self.type
self._model.type_ = self.type_
self._model.name = self.NODE_NAME
self._view = node
self._view.type = self.type
self._view.type_ = self.type_
self._view.name = self.model.name
self._view.id = self._model.id

def __repr__(self):
return '{}(\'{}\')'.format(self.type, self.NODE_NAME)
return '{}(\'{}\')'.format(self.type_, self.NODE_NAME)

def __eq__(self, other):
if isinstance(other, self.__class__):
Expand All @@ -57,7 +57,7 @@ def __ne__(self, other):
return not self.__eq__(other)

@classproperty
def type(cls):
def type_(cls):
"""
Node type identifier followed by the class name.
eg. com.chantasticvfx.MyNode
Expand Down Expand Up @@ -120,7 +120,7 @@ def model(self):

def set_model(self, model):
self._model = model
self._model.type = self.type
self._model.type_ = self.type_
self._model.id = self.view.id

def update_model(self):
Expand Down Expand Up @@ -439,7 +439,7 @@ def add_input(self, name='input', multi_input=False, display_name=True):
raise AssertionError('port name "{}" already taken.'.format(name))
view = self.view.add_input(name, multi_input, display_name)
port = Port(self, view)
port.model.type = IN_PORT
port.model.type_ = IN_PORT
port.model.name = name
port.model.display_name = display_name
port.model.multi_connection = multi_input
Expand All @@ -463,7 +463,7 @@ def add_output(self, name='output', multi_output=True, display_name=True):
raise AssertionError('port name "{}" already taken.'.format(name))
view = self.view.add_output(name, multi_output, display_name)
port = Port(self, view)
port.model.type = OUT_PORT
port.model.type_ = OUT_PORT
port.model.name = name
port.model.display_name = display_name
port.model.multi_connection = multi_output
Expand Down
8 changes: 4 additions & 4 deletions NodeGraphQt/base/port.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ def model(self):
"""
return self.__model

def type(self):
def type_(self):
"""
Returns the port type.

Returns:
str: 'in' for input port or 'out' for output port.
"""
return self.model.type
return self.model.type_

def multi_connection(self):
"""
Expand Down Expand Up @@ -126,9 +126,9 @@ def connected_ports(self):
for node_id, port_names in self.model.connected_ports.items():
for port_name in port_names:
node = graph.get_node_by_id(node_id)
if self.type() == 'in':
if self.type_() == 'in':
ports.append(node.outputs()[port_name])
elif self.type() == 'out':
elif self.type_() == 'out':
ports.append(node.inputs()[port_name])
return ports

Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/base/vendor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def register_node(self, node, alias=None):
return

name = node.NODE_NAME
node_type = node.type
node_type = node.type_

if self._nodes.get(node_type):
raise AssertionError(
Expand Down
Loading