Skip to content

Commit

Permalink
Merge pull request #400 from jchanvfx/property_bin_widget_tweaks
Browse files Browse the repository at this point in the history
exposed NodePropEditorWidget widget object.
  • Loading branch information
jchanvfx authored Jan 19, 2024
2 parents 7d86fd2 + 8ea5876 commit 8e41d48
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
6 changes: 5 additions & 1 deletion NodeGraphQt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ def __init__(self):
from .widgets.node_widgets import NodeBaseWidget
from .custom_widgets.nodes_tree import NodesTreeWidget
from .custom_widgets.nodes_palette import NodesPaletteWidget
from .custom_widgets.properties_bin.node_property_widgets import PropertiesBinWidget
from .custom_widgets.properties_bin.node_property_widgets import (
NodePropEditorWidget,
PropertiesBinWidget
)


__version__ = VERSION
Expand All @@ -78,6 +81,7 @@ def __init__(self):
'NodeGraphMenu',
'NodeObject',
'NodesPaletteWidget',
'NodePropEditorWidget',
'NodesTreeWidget',
'NodesMenu',
'Port',
Expand Down
33 changes: 28 additions & 5 deletions NodeGraphQt/custom_widgets/properties_bin/node_property_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,21 +302,21 @@ def set_lock_controls_disable(self, disable=False):
chb_widget.setDisabled(disable)


class NodePropWidget(QtWidgets.QWidget):
class NodePropEditorWidget(QtWidgets.QWidget):
"""
Node properties widget for display a Node object.
Node properties editor widget for display a Node object.
Args:
parent (QtWidgets.QWidget): parent object.
node (NodeGraphQt.BaseNode): node.
node (NodeGraphQt.NodeObject): node.
"""

#: signal (node_id, prop_name, prop_value)
property_changed = QtCore.Signal(str, str, object)
property_closed = QtCore.Signal(str)

def __init__(self, parent=None, node=None):
super(NodePropWidget, self).__init__(parent)
super(NodePropEditorWidget, self).__init__(parent)
self.__node_id = node.id
self.__tab_windows = {}
self.__tab = QtWidgets.QTabWidget()
Expand Down Expand Up @@ -537,6 +537,15 @@ def add_tab(self, name):
self.__tab.addTab(self.__tab_windows[name], name)
return self.__tab_windows[name]

def get_tab_widget(self):
"""
Returns the underlying tab widget.
Returns:
QtWidgets.QTabWidget: tab widget.
"""
return self.__tab

def get_widget(self, name):
"""
get property widget.
Expand Down Expand Up @@ -741,6 +750,20 @@ def __on_property_widget_changed(self, node_id, prop_name, prop_value):
if not self._block_signal:
self.property_changed.emit(node_id, prop_name, prop_value)

def create_property_editor(self, node):
"""
Creates a new property editor widget from the provided node.
(re-implement for displaying custom node property editor widget.)
Args:
node (NodeGraphQt.NodeObject): node object.
Returns:
NodePropEditorWidget: property editor widget.
"""
return NodePropEditorWidget(node=node)

def limit(self):
"""
Returns the limit for how many nodes can be loaded into the bin.
Expand Down Expand Up @@ -779,7 +802,7 @@ def add_node(self, node):

self._prop_list.insertRow(0)

prop_widget = NodePropWidget(node=node)
prop_widget = self.create_property_editor(node=node)
prop_widget.property_closed.connect(self.__on_prop_close)
prop_widget.property_changed.connect(self.__on_property_widget_changed)
port_connections = prop_widget.get_port_connection_widget()
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.6.30'
__version__ = '0.6.31'
__status__ = 'Work in Progress'
__license__ = 'MIT'

Expand Down

0 comments on commit 8e41d48

Please sign in to comment.