Skip to content

Commit 3d8e095

Browse files
committed
Update example for remote control
1 parent f334746 commit 3d8e095

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

example/BPNode/Example/Button/Simple.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,24 @@ class Simple(Blackprint.Node):
88
'Clicked': types.FunctionType
99
}
1010

11+
# Create interface for puppet node
12+
interfaceSync = [
13+
{'type': "button_in", 'id': "click", 'text': "Trigger", 'tooltip': "Trigger", 'inline': True}
14+
]
15+
1116
def __init__(this, instance):
1217
super(Simple, this).__init__(instance)
1318

1419
iface = this.setInterface('BPIC/Example/Button')
1520
iface.title = "Button"
1621

22+
# Remote sync in
23+
def syncIn(this, id, data):
24+
if(id == 'click' and data['press'] == False): this.iface.clicked()
25+
1726
@Blackprint.registerInterface('BPIC/Example/Button')
1827
class ButtonIFace(Blackprint.Interface):
1928
def clicked(this, ev = None):
2029
colorLog("Button/Simple:", "'Trigger' button clicked")
21-
this.node.output['Clicked']()
30+
this.node.output['Clicked']()
31+
this.node.syncOut('click', {'press': False})

example/BPNode/Example/Display/Logger.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ class Logger(Blackprint.Node):
99
'Any': Blackprint.Port.ArrayOf(Blackprint.Types.Any)
1010
}
1111

12+
# Create interface for puppet node
13+
interfaceSync = [
14+
{'type': "text_out", 'id': "log", 'placeholder': "...", 'tooltip': "Output will written here"},
15+
]
16+
1217
def __init__(this, instance):
1318
super(Logger, this).__init__(instance)
1419

@@ -26,7 +31,7 @@ def refreshLogger(this, val):
2631
this.iface.log = val
2732

2833
def init(this):
29-
def onCableConnection():
34+
def onCableConnection(ev):
3035
colorLog("Logger ("+(this.iface.id or '')+"):", "A cable was changed on Logger, now refresing the input element")
3136

3237
# Let's show data after new cable was connected or disconnected

example/BPNode/Example/Input/Simple.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ class Simple(Blackprint.Node):
99
'Value': str,
1010
}
1111

12+
# Create interface for puppet node
13+
interfaceSync = [
14+
{'type': "text_in", 'id': "value", 'placeholder': "Type text here..."},
15+
]
16+
1217
def __init__(this, instance):
1318
Blackprint.Node.__init__(this, instance)
1419

@@ -28,8 +33,11 @@ def imported(this, data):
2833
# Remote sync in
2934
def syncIn(this, id, data):
3035
if(id == 'data'):
31-
this.iface.data.value = data.value
32-
this.iface.changed(data.value)
36+
this.iface.data.value = data['value']
37+
this.iface.changed(data['value'])
38+
elif(id == 'value'):
39+
this.iface.data.value = data
40+
this.iface.changed(data)
3341

3442
class InputIFaceData:
3543
def __init__(this, iface):

example/BPNode/Example/Math/Multiply.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class Multiply(Blackprint.Node):
1515
# Define input port here
1616
input = {
1717
'Exec': Blackprint.Port.Trigger(Exec),
18-
'A': int,
18+
'A': float,
1919
'B': Blackprint.Types.Any,
2020
}
2121

2222
# Define output port here
2323
output = {
24-
'Result': int,
24+
'Result': float,
2525
}
2626

2727
def __init__(this, instance):

example/BPNode/Example/Math/Random.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
from random import randint
1+
from random import uniform
22
import Blackprint
33
from ...utils import colorLog
44

55
def ReSeed(port):
66
node = port.iface.node
77

88
node.executed = True
9-
node.output['Out'] = randint(0, 100)
9+
node.output['Out'] = uniform(0, 100)
1010

1111
# print("Re-seed called")
1212

1313
@Blackprint.registerNode('Example/Math/Random')
1414
class Random(Blackprint.Node):
1515
output = {
16-
'Out': int
16+
'Out': float
1717
}
1818

1919
input = {

0 commit comments

Comments
 (0)