Skip to content

Commit 16f299a

Browse files
add option to overwrite icons search path
update application screen shot remove name label in properties widget expose function to expand/collapse the properties area promote paremter to start widget with expanded properties
1 parent 8f105a2 commit 16f299a

File tree

4 files changed

+55
-26
lines changed

4 files changed

+55
-26
lines changed

docs/img/flowpipe-editor.png

22.5 KB
Loading

examples/vfx_rendering.py

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,36 @@
44
from flowpipe import Graph, Node
55
from Qt import QtGui, QtWidgets
66

7+
from flowpipe_editor import flowpipe_editor_widget
78
from flowpipe_editor.flowpipe_editor_widget import FlowpipeEditorWidget
89

910
BASE_PATH = Path(__file__).parent.parent.resolve()
1011

12+
# example to overwrite the icons path for
13+
flowpipe_editor_widget.ICONS_PATH = Path(
14+
Path(flowpipe_editor_widget.__file__).parent.resolve(),
15+
"icons",
16+
)
17+
18+
1119
@Node(outputs=["camera_file"], metadata={"interpreter": "3dequalizer"})
1220
def CreateCamera():
13-
"""Creates a shot camera.
14-
"""
21+
"""Creates a shot camera."""
1522
return {"camera_file": "/abs/camera.abc"}
1623

24+
1725
@Node(outputs=["scene_file"], metadata={"interpreter": "maya"})
1826
def MayaSceneGeneration(camera_file):
19-
"""Creates a Maya scene file for rendering.
20-
"""
27+
"""Creates a Maya scene file for rendering."""
2128
return {"scene_file": "/usd/scene.usd"}
2229

30+
2331
@Node(outputs=["renderings"], metadata={"interpreter": "houdini"})
2432
def HoudiniRender(frames, scene_file):
25-
"""Creates a Houdini scene file for rendering.
26-
"""
33+
"""Creates a Houdini scene file for rendering."""
2734
return {"renderings": "/renderings/file.%04d.exr"}
2835

36+
2937
@Node(outputs=["images"])
3038
def CheckImages(images):
3139
"""Check if the images are valid and return them."""
@@ -58,17 +66,17 @@ def UpdateDatabase(id_, images):
5866

5967
if __name__ == "__main__":
6068
graph = Graph(name="Rendering")
61-
frames, batch_size=30, 30
69+
frames, batch_size = 30, 30
6270
slapcomp = CreateSlapComp(graph=graph, template="nuke_template.nk")
6371
update_database = UpdateDatabase(graph=graph, id_=123456)
6472

65-
camera_creation = CreateCamera(graph=graph)
66-
scene_creation = MayaSceneGeneration(graph=graph)
67-
73+
camera_creation = CreateCamera(graph=graph)
74+
scene_creation = MayaSceneGeneration(graph=graph)
75+
6876
camera_creation.outputs["camera_file"].connect(
6977
scene_creation.inputs["camera_file"]
7078
)
71-
79+
7280
for i in range(0, frames, batch_size):
7381
houdini_render = HoudiniRender(
7482
name="HoudiniRender{0}-{1}".format(i, i + batch_size),
@@ -106,13 +114,19 @@ def UpdateDatabase(id_, images):
106114

107115
# Display the graph
108116
app = QtWidgets.QApplication(sys.argv)
109-
app.setWindowIcon(QtGui.QIcon(str(Path(BASE_PATH, 'flowpipe_editor', 'icons', 'flowpipe.png'))))
117+
app.setWindowIcon(
118+
QtGui.QIcon(
119+
str(Path(BASE_PATH, "flowpipe_editor", "icons", "flowpipe.png"))
120+
)
121+
)
110122

111123
window = QtWidgets.QWidget()
112124
window.setWindowTitle("Flowpipe-Editor VFX Rendering Example")
113125
window.resize(1100, 800)
114126

115-
flowpipe_editor_widget = FlowpipeEditorWidget(parent=window)
127+
flowpipe_editor_widget = FlowpipeEditorWidget(
128+
expanded_properties=False, parent=window
129+
)
116130
flowpipe_editor_widget.load_graph(graph)
117131
layout = QtWidgets.QVBoxLayout()
118132
layout.setContentsMargins(0, 0, 0, 0)
@@ -121,4 +135,4 @@ def UpdateDatabase(id_, images):
121135

122136
window.show()
123137

124-
sys.exit(app.exec())
138+
sys.exit(app.exec())

flowpipe_editor/flowpipe_editor_widget.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
)
1515

1616
BASE_PATH = Path(__file__).parent.resolve()
17+
ICONS_PATH = Path(BASE_PATH, "icons")
1718

1819

1920
class FlowpipeNode(BaseNode):
@@ -31,10 +32,16 @@ def __init__(self, **kwargs):
3132
class FlowpipeEditorWidget(QtWidgets.QWidget):
3233
"""Flowpipe editor widget for visualize flowpipe graphs."""
3334

34-
def __init__(self, parent: QtWidgets.QWidget = None):
35+
def __init__(
36+
self,
37+
expanded_properties: bool = False,
38+
parent: QtWidgets.QWidget = None,
39+
):
3540
"""Initialize the Flowpipe editor widget.
3641
3742
Args:
43+
expanded_properties (bool, optional): Whether to expand the properties
44+
bin initially. Defaults to False.
3845
parent (QtWidgets.QWidget, optional): Parent Qt Widget. Defaults to None.
3946
"""
4047
super().__init__(parent)
@@ -64,15 +71,13 @@ def __init__(self, parent: QtWidgets.QWidget = None):
6471
self.splitter.addWidget(properties_bin)
6572

6673
# hide initially
67-
self.splitter.setSizes([1, 0])
68-
69-
# example show the node properties bin widget when a node is double-clicked.
70-
def display_properties_bin():
71-
if self.splitter.sizes()[1] == 0:
72-
self.splitter.setSizes([700, 10])
74+
if not expanded_properties:
75+
self.collapse_properties_bin()
76+
else:
77+
self.expand_properties_bin()
7378

7479
# wire function to "node_double_clicked" signal.
75-
self.graph.node_selected.connect(display_properties_bin)
80+
self.graph.node_selected.connect(self.expand_properties_bin)
7681

7782
# get the main context menu.
7883
context_menu = self.graph.get_context_menu("graph")
@@ -85,6 +90,15 @@ def display_properties_bin():
8590
layout_menu.add_command("Vertical", self.layout_graph_up, "Shift+2")
8691
apply_dark_theme(self)
8792

93+
def collapse_properties_bin(self):
94+
"""Collapse the properties bin to show node properties."""
95+
self.splitter.setSizes([1, 0])
96+
97+
def expand_properties_bin(self):
98+
"""Expand the properties bin to show node properties."""
99+
if self.splitter.sizes()[1] == 0:
100+
self.splitter.setSizes([700, 10])
101+
88102
def layout_graph_down(self):
89103
"""
90104
Auto layout the nodes down stream.
@@ -119,13 +133,15 @@ def _add_node(self, fp_node, point):
119133

120134
# set icon based on interpreter
121135
if interpreter:
122-
icon_path = Path(BASE_PATH, "icons", f"{interpreter}.png")
136+
icon_path = Path(ICONS_PATH, f"{interpreter}.png")
123137
if icon_path.exists():
124138
qt_node.set_icon(str(icon_path))
125139
elif interpreter:
126-
qt_node.set_icon(str(Path(BASE_PATH, "icons", "python.png")))
140+
qt_node.set_icon(
141+
str(Path(Path(BASE_PATH, "icons"), "python.png"))
142+
)
127143
else:
128-
qt_node.set_icon(str(Path(BASE_PATH, "icons", "python.png")))
144+
qt_node.set_icon(str(Path(Path(BASE_PATH, "icons"), "python.png")))
129145

130146
for input_ in fp_node.all_inputs().values():
131147
qt_node.add_input(input_.name)

flowpipe_editor/widgets/properties_bin/node_property_widgets.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ def __init__(self, parent=None, node=None):
9090
name_layout = QtWidgets.QHBoxLayout()
9191
name_layout.setContentsMargins(0, 0, 0, 0)
9292
name_layout.addWidget(icon_label)
93-
name_layout.addWidget(QtWidgets.QLabel("name"))
9493
name_layout.addWidget(self.name_wgt)
9594
name_layout.addWidget(close_btn)
9695
layout = QtWidgets.QVBoxLayout(self)

0 commit comments

Comments
 (0)