Flowchart.py 1.17 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- coding: utf-8 -*-
import sys, os

## Make sure pyqtgraph is importable
p = os.path.dirname(os.path.abspath(__file__))
p = os.path.join(p, '..', '..')
sys.path.insert(0, p)


from pyqtgraph.flowchart import Flowchart
from pyqtgraph.Qt import QtGui

#import pyqtgraph.flowchart as f

app = QtGui.QApplication([])

#TETRACYCLINE = True

fc = Flowchart(terminals={
    'dataIn': {'io': 'in'},
    'dataOut': {'io': 'out'}    
})
w = fc.widget()
w.resize(400,200)
w.show()

27
28
29
30
n1 = fc.createNode('Add', pos=(0,-80))
n2 = fc.createNode('Subtract', pos=(140,-10))
n3 = fc.createNode('Abs', pos=(0, 80))
n4 = fc.createNode('Add', pos=(140,100))
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

fc.connectTerminals(fc.dataIn, n1.A)
fc.connectTerminals(fc.dataIn, n1.B)
fc.connectTerminals(fc.dataIn, n2.A)
fc.connectTerminals(n1.Out, n4.A)
fc.connectTerminals(n1.Out, n2.B)
fc.connectTerminals(n2.Out, n3.In)
fc.connectTerminals(n3.Out, n4.B)
fc.connectTerminals(n4.Out, fc.dataOut)


def process(**kargs):
    return fc.process(**kargs)

    
print process(dataIn=7)

fc.setInput(dataIn=3)

s = fc.saveState()
fc.clear()

fc.restoreState(s)

fc.setInput(dataIn=3)

#f.NodeMod.TETRACYCLINE = False

if sys.flags.interactive == 0:
    app.exec_()