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
2 changes: 2 additions & 0 deletions NodeGraphQt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,15 @@ def __init__(self):
from .widgets.node_tree import NodeTreeWidget
from .widgets.properties_bin import PropertiesBinWidget
from .widgets.node_publish_widget import NodePublishWidget
from .widgets.node_widgets import NodeBaseWidget


__version__ = VERSION
__all__ = [
'BackdropNode',
'BaseNode',
'LICENSE',
'NodeBaseWidget',
'NodeGraph',
'NodeGraphCommand',
'NodeGraphMenu',
Expand Down
20 changes: 12 additions & 8 deletions NodeGraphQt/base/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .port import Port
from .utils import update_node_down_stream
from ..constants import (NODE_PROP,
NODE_PROP_QLABEL,
NODE_PROP_QLINEEDIT,
NODE_PROP_QTEXTEDIT,
NODE_PROP_QCOMBO,
Expand All @@ -15,7 +16,7 @@
NODE_LAYOUT_VERTICAL,
NODE_LAYOUT_HORIZONTAL,
NODE_LAYOUT_DIRECTION)
from ..errors import PortRegistrationError,NodeWidgetError
from ..errors import PortRegistrationError, NodeWidgetError
from ..qgraphics.node_backdrop import BackdropNodeItem
from ..qgraphics.node_base import NodeItem, NodeItemVertical
from ..widgets.node_widgets import (NodeBaseWidget,
Expand Down Expand Up @@ -628,28 +629,31 @@ def get_widget(self, name):
"""
return self.view.widgets.get(name)

def add_custom_widget(self, name, widget=None, widget_type=NODE_PROP,
tab=None):
def add_custom_widget(self, widget, widget_type=NODE_PROP_QLABEL, tab=None):
"""
Add a custom node widget into the node.

see example :ref:`Embedding Custom Widgets`.

Note:
The ``value_changed`` signal from the added node widget is wired
up to the :meth:`NodeObject.set_property` function.

Args:
name (str): name for the custom property.
widget (NodeBaseWidget): custom node widget.
widget_cls (NodeBaseWidget): node widget class object.
widget_type: widget flag to display in the
:class:`NodeGraphQt.PropertiesBinWidget`.
:class:`NodeGraphQt.PropertiesBinWidget` (default: QLabel).
tab (str): name of the widget tab to display in.
"""
if not isinstance(widget, NodeBaseWidget):
raise NodeWidgetError(
'\'widget\' must be an instance of a NodeBaseWidget')
self.create_property(
name, widget.value, widget_type=widget_type, tab=tab)
self.create_property(widget.get_name(),
widget.get_value(),
widget_type=widget_type,
tab=tab)
widget.value_changed.connect(lambda k, v: self.set_property(k, v))
widget._node = self
self.view.add_widget(widget)

def add_combo_menu(self, name, label='', items=None, tab=None):
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/pkg_info.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
__version__ = '0.1.1'
__version__ = '0.1.2'
__status__ = 'Work in Progress'
__license__ = 'MIT'

Expand Down
4 changes: 2 additions & 2 deletions NodeGraphQt/qgraphics/node_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ def height(self, height=0.0):
def disabled(self, state=False):
AbstractNodeItem.disabled.fset(self, state)
for n, w in self._widgets.items():
w.widget.setDisabled(state)
w.get_custom_widget().setDisabled(state)
self._tooltip_disable(state)
self._x_item.setVisible(state)

Expand Down Expand Up @@ -800,7 +800,7 @@ def widgets(self):
return self._widgets.copy()

def add_widget(self, widget):
self._widgets[widget.name] = widget
self._widgets[widget.get_name()] = widget

def get_widget(self, name):
widget = self._widgets.get(name)
Expand Down
Loading