Skip to content

Commit 16165ef

Browse files
committed
upgrade and fix AutoNode examples
1 parent d46ad6a commit 16165ef

File tree

4 files changed

+43
-30
lines changed

4 files changed

+43
-30
lines changed

example_auto_nodes/basic_nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(self):
2121
# create node outputs.
2222
self.add_output('out A')
2323
self.add_output('out B')
24-
24+
self.set_icon("example_auto_nodes/pear.png")
2525

2626
class BarNode(AutoNode):
2727
"""

example_auto_nodes/input_nodes.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,34 @@ def __init__(self):
7777
def run(self):
7878
path = self.get_property('path')
7979
if os.path.exists(path):
80-
with open(path, 'r') as fread:
81-
data = fread.read()
82-
self.set_property('output', data)
80+
try:
81+
with open(path, 'r') as fread:
82+
data = fread.read()
83+
self.set_property('out', data)
84+
except Exception as e:
85+
self.error(e)
8386
else:
84-
print('No existe %s' % path)
85-
self.set_property('output', '')
87+
self.error('No existe %s' % path)
88+
self.set_property('out', '')
89+
90+
91+
class TextInputNode(AutoNode):
92+
"""
93+
An example of a node with a embedded QLineEdit.
94+
"""
95+
96+
# unique node identifier.
97+
__identifier__ = 'Inputs'
98+
99+
# initial default node name.
100+
NODE_NAME = 'text'
101+
102+
def __init__(self):
103+
super(TextInputNode, self).__init__()
104+
105+
# create input & output ports
106+
self.add_output('out')
107+
108+
# create QLineEdit text input widget.
109+
self.add_text_input('out', 'Text Input', tab='widgets')
110+
self.view.widgets['out'].value_changed.connect(self.cook)

example_auto_nodes/math_node.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ def run(self):
9292
self.error("Error : %s" % str(error))
9393

9494
class VectorValue(AutoNode):
95+
"""
96+
Create a basic vector data
97+
"""
98+
9599
__identifier__ = 'Math'
96100
NODE_NAME = 'Vector'
97101

@@ -119,6 +123,10 @@ def updateValue(self, index):
119123

120124

121125
class VectorSplit(AutoNode):
126+
"""
127+
Splict a vector to x,y,z
128+
"""
129+
122130
__identifier__ = 'Math'
123131
NODE_NAME = 'Vector Split'
124132

@@ -135,8 +143,6 @@ def __init__(self):
135143

136144
self.add_input("in vector",list)
137145

138-
139-
140146
def run(self):
141147
value = self.getInputData(0)
142148
self.set_property("x", value[0])
@@ -145,6 +151,10 @@ def run(self):
145151

146152

147153
class VectorMaker(AutoNode):
154+
"""
155+
Create a vector by three float value
156+
"""
157+
148158
__identifier__ = 'Math'
149159
NODE_NAME = 'Vector Maker'
150160

example_auto_nodes/widget_nodes.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,6 @@ def __init__(self):
2525
self.add_combo_menu('my_menu', 'Menu Test', items=items)
2626

2727

28-
class TextInputNode(AutoNode):
29-
"""
30-
An example of a node with a embedded QLineEdit.
31-
"""
32-
33-
# unique node identifier.
34-
__identifier__ = 'com.chantasticvfx'
35-
36-
# initial default node name.
37-
NODE_NAME = 'text'
38-
39-
def __init__(self):
40-
super(TextInputNode, self).__init__()
41-
42-
# create input & output ports
43-
self.add_input('in')
44-
self.add_output('out')
45-
46-
# create QLineEdit text input widget.
47-
self.add_text_input('my_input', 'Text Input', tab='widgets')
48-
49-
5028
class CheckboxNode(AutoNode):
5129
"""
5230
An example of a node with 2 embedded QCheckBox widgets.

0 commit comments

Comments
 (0)