Connections¶
Here you can learn how to connect and disconnect objects in pdpy
.
The code we’ll execute is here:
1import pdpy_lib as pdpy
2pd = pdpy.PdPy(name='test_disconnect',root=True)
3obj = pdpy.Obj('loadbang')
4printer = pdpy.Obj('print')
5pd.create(obj, printer)
6pd.connect(obj,printer)
7pd.__arrange__(pd)
8print(pd.__pd__())
9pd.disconnect(obj,printer)
10print(pd.__pd__())
First, we import pdpy_lib as pdpy and create a PdPy instance:
>>> import pdpy_lib as pdpy
>>> pd = pdpy.PdPy(name='test_disconnect',root=True)
Found darwin platform.
Locating pd...
Found pd at: /Applications/Pd-0.52-2.app/Contents/Resources/bin/pd
Then, we create a loadbang and a printer, to test:
>>> obj = pdpy.Obj('loadbang')
>>> printer = pdpy.Obj('print')
>>> pd.create(obj, printer)
<pdpy.PdPy object at 0x106596820>
We connect them, and let’s arrange them so that we can print them:
>>> pd.connect(obj,printer)
>>> pd.__arrange__(pd)
Initialized Arranger graph placing algorithm.
>>> print(pd.__pd__())
#N canvas 0 22 450 300 12;
#X obj 10 10 loadbang;
#X obj 10 58 print;
#X connect 0 0 1 0;
Now, try disconnecting them:
>>> pd.disconnect(obj,printer)
Disconnected 0
Let’s see the result:
>>> print(pd.__pd__())
#N canvas 0 22 450 300 12;
#X obj 10 10 loadbang;
#X obj 10 58 print;