Skip to content

Commit 42797ab

Browse files
committed
backdrop wrap nodes.
1 parent 508f907 commit 42797ab

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

NodeGraphQt/base/node.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,15 @@ def auto_size(self):
12181218
"""
12191219
self.view.auto_resize()
12201220

1221+
def wrap_nodes(self, nodes):
1222+
"""
1223+
Wrap backdrop size to fit around specified nodes.
1224+
1225+
Args:
1226+
nodes (list[NodeGraphQt.NodeObject]): list of nodes.
1227+
"""
1228+
self.view.auto_resize([n.view for n in nodes])
1229+
12211230
def nodes(self):
12221231
"""
12231232
Returns nodes wrapped within the backdrop node.

example.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,15 @@ def show_nodes_list(node):
214214
bar_node.set_name('icon node')
215215
bar_node.set_pos(-70, 10)
216216

217-
# connect the nodes
217+
# connect the nodes.
218218
foo_node.set_output(0, bar_node.input(2))
219219
menu_node.set_input(0, bar_node.output(1))
220220
bar_node.set_input(0, text_node.output(0))
221221

222+
# wrap a backdrop node.
223+
backdrop_node = graph.create_node('nodeGraphQt.nodes.BackdropNode')
224+
backdrop_node.wrap_nodes([my_node, menu_node])
225+
222226
graph.fit_to_selection()
223227

224228
app.exec_()

0 commit comments

Comments
 (0)