Core¶
Base¶
- class pdpy_lib.core.base.Base(patchname=None, pdtype=None, cls=None, json=None, xml=None, default=None)[source]¶
Bases:
XmlBuilder
,XmlTagConvert
The base class for all pdpy objects
- Parameters
patchname (
str
orNone
) – Name of the Pd patch file (default:None
)pdtype (
str
orNone
) – Type of the Pd object:X
,N
, orA
(default:X
)cls (
str
orNone
) – Class of the Pd object, eg.:msg
,text
, … (default:obj
)json (
dict
orNone
) – A json dictionary of key/value pairs to populate the object.xml (
xml.etree.ElementTree.Element
orNone
) – An Xml Element with the appropriate element structure.default (
pdpy_lib.utilities.default.Default
orNone
) – A class containing a template for default values.
- __pd__(args=None)[source]¶
Returns a the pd line for this object
Called by all derived classes to return a Pd line for this object. If
args
is present the pd line will end with;\r\n
, and:If
args
is a list of strings, each element is appended to the pd line:#N canvas >>> 0 22 340 520 12 >>> ; <<<
If
args
is a string, it is appended to the pd line:#X obj >>> 10 30 print >>> ; <<<
If
args
isNone
, the pd line is returned without arguments:#X connect >>> <<<
- Parameters
args (
list
ofstr
orstr
orNone
) – The arguments to the pd line.- Returns
the pd line for this object built with
__type__
and__cls__
- Return type
str
- __xml_load__(xml_tree)[source]¶
Parse an XML tree into a PdPy object
Called if loading a PdPy object from an XML file.
Note
This method assumes it belongs to a PdPy class, because:
pdpy_lib.patching.pdpy.PdPy
basespdpy_lib.core.base.Base
- addpos(x, y)[source]¶
Adds or updates the position
pdpy_lib.primitives.point.Point
Canvas Base¶
- class pdpy_lib.core.canvasbase.CanvasBase(obj_idx=0, isroot=False)[source]¶
Bases:
XmlBuilder
Base class for a canvas
This class is based by
pdpy_lib.patching.pdpy.PdPy
andpdpy_lib.patching.canvas.Canvas
- add(node)[source]¶
Add (append) a Node to this canvas
nodes
This method creates and/or appends a node to an internal array
nodes
. Each node is a Pure Data object that is neither a comment nor a connection- Returns
The position (index) of the most recently added node
- Return type
int
- comment(comment)[source]¶
Append a pure data comment
This method creates and/or appends a pure data comment.
- Return type
None
Object Class Definitions
- class pdpy_lib.core.object.Object(id=None, x=None, y=None, **kwargs)[source]¶
Bases:
Base
A Object base class
A Object holds the id, and the x and y coordinates of the pd object, as well as the arguments array.
- - `addargs(argv)`: Adds arguments to the pd object.
Message¶
- class pdpy_lib.core.message.Message(address=None, json=None, xml=None)[source]¶
Bases:
Base
Representation of a Pd Message (non patchable, used by
pdpy_lib.objects.msg.Msg
)This class represents a Pd message. It stores a list of messages, together with a
address
. If no address is given, the default is the outlet. Otherwise, messages are sent to that address.- Parameters
address (
str
orNone
) – (optional) The target address of the message (default:"outlet"
)json (
dict
orNone
) – (optional) A json dictionary with the scope of a Messagexml (
xml.etree.ElementTree.Element
orNone
) – (optional) An xml Element with the scope of a Message