Block

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.lilypondfile" { graph [label="abjad.lilypondfile"]; node [color=1]; "abjad.lilypondfile.Block.Block" [URL="../api/abjad/lilypondfile/Block.html#abjad.lilypondfile.Block.Block", color=black, fontcolor=white, label=Block, target=_top]; "abjad.lilypondfile.ContextBlock.ContextBlock" [URL="../api/abjad/lilypondfile/ContextBlock.html#abjad.lilypondfile.ContextBlock.ContextBlock", label="Context\nBlock", target=_top]; "abjad.lilypondfile.Block.Block" -> "abjad.lilypondfile.ContextBlock.ContextBlock"; } subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=2]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/lilypondfile/../system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } "abjad.system.AbjadObject.AbjadObject" -> "abjad.lilypondfile.Block.Block"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjad.lilypondfile.Block.Block(name='score')

A LilyPond file block.

REGRESSION. Blocks remember attribute assignment order.

Here right margin precedes left margin even though left margin alphabetizes before right margin:

>>> block = abjad.Block(name='paper')
>>> block.right_margin = abjad.LilyPondDimension(2, 'cm')
>>> block.left_margin = abjad.LilyPondDimension(2, 'cm')
>>> block
<Block(name='paper')>
>>> abjad.f(block)
\paper {
    right-margin = 2\cm
    left-margin = 2\cm
}
>>> block = abjad.Block(name='score')
>>> markup = abjad.Markup('foo')
>>> block.items.append(markup)
>>> block
<Block(name='score')>
>>> abjad.f(block)
\score {
    {
        \markup { foo }
    }
}

Attributes Summary

__delattr__ Deletes block attribute with name.
__format__ Formats block.
__getitem__ Gets item with name.
__setattr__ Sets block name to value.
empty Is true when block contains no items and has no user attributes.
items Gets items in block.
name Gets name of block.

Special methods

__delattr__(name)

Deletes block attribute with name.

>>> header_block = abjad.Block(name='header')
>>> header_block.tagline = False
>>> header_block.tagline
False
>>> delattr(header_block, 'tagline')
>>> hasattr(header_block, 'tagline')
False
Return type:None
__format__(format_specification='')

Formats block.

Returns string.

__getitem__(name)

Gets item with name.

Gets score with name 'Red Example Score' in score block:

>>> block = abjad.Block(name='score')
>>> score = abjad.Score(name='Red Example Score')
>>> block.items.append(score)
>>> block['Red Example Score']
Score(is_simultaneous=True, name='Red Example Score')

Returns item.

Raises key error when no item with name is found.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

__setattr__(name, value)

Sets block name to value.

Returns none.


Methods

empty()

Is true when block contains no items and has no user attributes.

Returns true or false.


Read-only properties

items

Gets items in block.

>>> block = abjad.Block(name='score')
>>> markup = abjad.Markup('foo')
>>> block.items.append(markup)
>>> block.items
[Markup(contents=['foo'])]

Accepts strings:

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> score_block = abjad.Block(name='score')
>>> score_block.items.append('<<')
>>> score_block.items.append(r'{ \include "layout.ly" }')
>>> score_block.items.append(staff)
>>> score_block.items.append('>>')
>>> lilypond_file = abjad.LilyPondFile(
...     lilypond_language_token=False,
...     lilypond_version_token=False,
...     )
>>> lilypond_file.items.append(score_block)
>>> abjad.f(lilypond_file)
\score {
    <<
    { \include "layout.ly" }
    \new Staff
    {
        c'4
        d'4
        e'4
        f'4
    }
    >>
}

Returns list.

name

Gets name of block.

>>> block = abjad.Block(name='score')
>>> markup = abjad.Markup('foo')
>>> block.items.append(markup)
>>> block.name
'score'

Returns string.