From 8ea5876a0a33a9eadc99feaa070b82d126bc13ce Mon Sep 17 00:00:00 2001 From: jchan Date: Fri, 19 Jan 2024 16:32:04 +1300 Subject: [PATCH] exposed NodePropEditorWidget widget object. --- NodeGraphQt/__init__.py | 6 +++- .../properties_bin/node_property_widgets.py | 33 ++++++++++++++++--- NodeGraphQt/pkg_info.py | 2 +- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/NodeGraphQt/__init__.py b/NodeGraphQt/__init__.py index 79d59fe5..5ac835fc 100644 --- a/NodeGraphQt/__init__.py +++ b/NodeGraphQt/__init__.py @@ -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 @@ -78,6 +81,7 @@ def __init__(self): 'NodeGraphMenu', 'NodeObject', 'NodesPaletteWidget', + 'NodePropEditorWidget', 'NodesTreeWidget', 'NodesMenu', 'Port', diff --git a/NodeGraphQt/custom_widgets/properties_bin/node_property_widgets.py b/NodeGraphQt/custom_widgets/properties_bin/node_property_widgets.py index e3a14116..75bc5717 100644 --- a/NodeGraphQt/custom_widgets/properties_bin/node_property_widgets.py +++ b/NodeGraphQt/custom_widgets/properties_bin/node_property_widgets.py @@ -302,13 +302,13 @@ 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) @@ -316,7 +316,7 @@ class NodePropWidget(QtWidgets.QWidget): 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() @@ -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. @@ -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. @@ -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() diff --git a/NodeGraphQt/pkg_info.py b/NodeGraphQt/pkg_info.py index 9600fa89..00e6d8c8 100644 --- a/NodeGraphQt/pkg_info.py +++ b/NodeGraphQt/pkg_info.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -__version__ = '0.6.30' +__version__ = '0.6.31' __status__ = 'Work in Progress' __license__ = 'MIT'