LabelAgent

class agenttools.LabelAgent(client=None)

Label agent.

>>> staff = Staff("c'4 e'4 d'4 f'4")
>>> show(staff) 
>>> label(staff)
LabelAgent(client=Staff("c'4 e'4 d'4 f'4"))

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_agenttools { graph [label=agenttools]; "abjad.tools.agenttools.LabelAgent.LabelAgent" [color=black, fontcolor=white, group=1, label=<<B>LabelAgent</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=3, group=2, label=object, shape=box]; } "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.agenttools.LabelAgent.LabelAgent"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

client Gets client of label agent.
color_container([color]) Colors contents of container.
color_leaves([color]) Colors leaves.
color_note_heads([color_map]) Colors note note heads.
remove_markup() Removes markup from leaves.
vertical_moments([direction, prototype]) Labels vertical moments.
with_durations([direction, ...]) Labels logical ties with durations.
with_indices([direction, prototype]) Labels logical ties with indices.
with_intervals([direction, prototype]) Labels consecutive notes with intervals.
with_pitches([direction, prototype]) Labels logical ties with pitches.
with_start_offsets([clock_time, direction, ...]) Labels logical ties with start offsets.
__eq__(expr) Is true when ID of expr equals ID of Abjad object.
__format__([format_specification]) Formats Abjad object.
__hash__() Hashes Abjad object.
__ne__(expr) Is true when Abjad object does not equal expr.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

LabelAgent.client

Gets client of label agent.

Returns component, selection, spanner or none.

Methods

LabelAgent.color_container(color='red')

Colors contents of container.

Example 1. Colors measure:

>>> measure = Measure((2, 8), "c'8 d'8")
>>> label(measure).color_container('red')
>>> show(measure) 

Returns none.

LabelAgent.color_leaves(color='red')

Colors leaves.

Example 1. Colors leaves red:

>>> staff = Staff("cs'8. [ r8. s8. <c' cs' a'>8. ]")
>>> show(staff) 
>>> label(staff).color_leaves('red')
>>> show(staff) 

Returns none.

LabelAgent.color_note_heads(color_map=None)

Colors note note heads.

Example 1. Colors chord note heads:

>>> chord = Chord([12, 14, 18, 21, 23], (1, 4))
>>> pitches = [[-12, -10, 4], [-2, 8, 11, 17], [19, 27, 30, 33, 37]]
>>> colors = ['red', 'blue', 'green']
>>> color_map = pitchtools.NumberedPitchClassColorMap(pitches, colors)
>>> label(chord).color_note_heads(color_map)
>>> show(chord) 

Example 2. Colors note note head:

>>> note = Note("c'4")
>>> label(note).color_note_heads(color_map)
>>> show(note) 

Example 3. Colors nothing:

>>> staff = Staff([])
>>> label(staff).color_note_heads(color_map)

Example 4. Colors note heads:

>>> staff = Staff("c'8 cs'8 d'8 ds'8 e'8 f'8 fs'8 g'8 gs'8 a'8 as'8 b'8 c''8")
>>> label(staff).color_note_heads()
>>> show(staff) 

Returns none.

LabelAgent.remove_markup()

Removes markup from leaves.

Example.

>>> staff = Staff("c'8 d'8 e'8 f'8")
>>> label(staff).with_pitches()
>>> show(staff) 
>>> label(staff).remove_markup()
>>> show(staff) 

Returns none.

LabelAgent.vertical_moments(direction=Up, prototype=None)

Labels vertical moments.

Example 1. Labels indices:

>>> staff_group = StaffGroup([])
>>> staff = Staff("c'8 d'4 e'16 f'16")
>>> staff_group.append(staff)
>>> staff = Staff(r"""\clef "alto" g4 f4""")
>>> staff_group.append(staff)
>>> staff = Staff(r"""\clef "bass" c,2""")
>>> staff_group.append(staff)
>>> label(staff_group).vertical_moments()
>>> show(staff_group) 

Example 2. Labels pitch numbers:

>>> staff_group = StaffGroup([])
>>> staff = Staff("c'8 d'4 e'16 f'16")
>>> staff_group.append(staff)
>>> staff = Staff(r"""\clef "alto" g4 f4""")
>>> staff_group.append(staff)
>>> staff = Staff(r"""\clef "bass" c,2""")
>>> staff_group.append(staff)
>>> prototype = pitchtools.NumberedPitch
>>> label(staff_group).vertical_moments(prototype=prototype)
>>> show(staff_group) 

Example 3. Labels pitch-class numbers:

>>> staff_group = StaffGroup([])
>>> staff = Staff("c'8 d'4 e'16 f'16")
>>> staff_group.append(staff)
>>> staff = Staff(r"""\clef "alto" g4 f4""")
>>> staff_group.append(staff)
>>> staff = Staff(r"""\clef "bass" c,2""")
>>> staff_group.append(staff)
>>> prototype = pitchtools.NumberedPitchClass
>>> label(staff_group).vertical_moments(prototype=prototype)
>>> show(staff_group) 

Example 4. Labels interval numbers:

>>> staff_group = StaffGroup([])
>>> staff = Staff("c'8 d'4 e'16 f'16")
>>> staff_group.append(staff)
>>> staff = Staff(r"""\clef "alto" g4 f4""")
>>> staff_group.append(staff)
>>> staff = Staff(r"""\clef "bass" c,2""")
>>> staff_group.append(staff)
>>> prototype = pitchtools.NumberedInterval
>>> label(staff_group).vertical_moments(prototype=prototype)
>>> show(staff_group) 

Example 5. Labels interval-class numbers:

>>> staff_group = StaffGroup([])
>>> staff = Staff("c'8 d'4 e'16 f'16")
>>> staff_group.append(staff)
>>> staff = Staff(r"""\clef "alto" g4 f4""")
>>> staff_group.append(staff)
>>> staff = Staff(r"""\clef "bass" c,2""")
>>> staff_group.append(staff)
>>> prototype = pitchtools.NumberedIntervalClass
>>> label(staff_group).vertical_moments(prototype=prototype)
>>> show(staff_group) 

Example 6. Labels interval-class vectors:

>>> staff_group = StaffGroup([])
>>> staff = Staff("c'8 d'4 e'16 f'16")
>>> staff_group.append(staff)
>>> staff = Staff(r"""\clef "alto" g4 f4""")
>>> staff_group.append(staff)
>>> staff = Staff(r"""\clef "bass" c,2""")
>>> staff_group.append(staff)
>>> prototype = pitchtools.IntervalClassVector
>>> label(staff_group).vertical_moments(prototype=prototype)
>>> show(staff_group) 

Set prototype to one of the classes shown above.

Returns none.

LabelAgent.with_durations(direction=Up, preferred_denominator=None)

Labels logical ties with durations.

Example 1. Labels logical tie durations:

>>> staff = Staff(r"c'4. d'8 ~ d'4. e'16 [ ef'16 ]")
>>> label(staff).with_durations()
>>> show(staff) 

Example 2. Labels logical ties with preferred denominator:

>>> staff = Staff(r"c'4. d'8 ~ d'4. e'16 [ ef'16 ]")
>>> label(staff).with_durations(preferred_denominator=16)
>>> show(staff) 

Returns none.

LabelAgent.with_indices(direction=Up, prototype=None)

Labels logical ties with indices.

Example 1. Labels logical tie indices:

>>> staff = Staff("<c' bf'>8 <g' a'>4 af'8 ~ af'8 gf'8 ~ gf'4")
>>> label(staff).with_indices()
>>> override(staff).text_script.staff_padding = 2
>>> show(staff) 

Example 2. Labels note indices:

>>> staff = Staff("<c' bf'>8 <g' a'>4 af'8 ~ af'8 gf'8 ~ gf'4")
>>> label(staff).with_indices(prototype=Note)
>>> override(staff).text_script.staff_padding = 2
>>> show(staff) 

Example 3. Labels chord indices:

>>> staff = Staff("<c' bf'>8 <g' a'>4 af'8 ~ af'8 gf'8 ~ gf'4")
>>> label(staff).with_indices(prototype=Chord)
>>> override(staff).text_script.staff_padding = 2
>>> show(staff) 

Example 4. Labels leaf indices:

>>> staff = Staff("<c' bf'>8 <g' a'>4 af'8 ~ af'8 gf'8 ~ gf'4")
>>> label(staff).with_indices(prototype=scoretools.Leaf)
>>> override(staff).text_script.staff_padding = 2
>>> show(staff) 

Example 5. Labels tuplet indices:

>>> staff = Staff(4 * Tuplet((2, 3), "c'8 [ d'8 e'8 ]"))
>>> label(staff).with_indices(prototype=Tuplet)
>>> override(staff).text_script.staff_padding = 2
>>> show(staff) 

Returns none.

LabelAgent.with_intervals(direction=Up, prototype=None)

Labels consecutive notes with intervals.

Example 1. Labels consecutive notes with interval names:

>>> pitch_numbers = [0, 25, 11, -4, -14, -13, 9, 10]
>>> notes = scoretools.make_notes(pitch_numbers, [(1, 4)])
>>> staff = Staff(notes)
>>> label(staff).with_intervals(prototype=None)
>>> override(staff).text_script.staff_padding = 4
>>> show(staff) 

Example 2. Labels consecutive notes with interval-class names:

>>> pitch_numbers = [0, 25, 11, -4, -14, -13, 9, 10]
>>> notes = scoretools.make_notes(pitch_numbers, [(1, 4)])
>>> staff = Staff(notes)
>>> prototype = pitchtools.NamedIntervalClass
>>> label(staff).with_intervals(prototype=prototype)
>>> override(staff).text_script.staff_padding = 4
>>> show(staff) 

Example 3. Labels consecutive notes with interval numbers:

>>> pitch_numbers = [0, 25, 11, -4, -14, -13, 9, 10]
>>> notes = scoretools.make_notes(pitch_numbers, [(1, 4)])
>>> staff = Staff(notes)
>>> prototype = pitchtools.NumberedInterval
>>> label(staff).with_intervals(prototype=prototype)
>>> override(staff).text_script.staff_padding = 4
>>> show(staff) 

Example 4. Labels consecutive notes with interval-class numbers:

>>> pitch_numbers = [0, 25, 11, -4, -14, -13, 9, 10]
>>> notes = scoretools.make_notes(pitch_numbers, [(1, 4)])
>>> staff = Staff(notes)
>>> prototype = pitchtools.NumberedIntervalClass
>>> label(staff).with_intervals(prototype=prototype)
>>> override(staff).text_script.staff_padding = 4
>>> show(staff) 

Example 5. Labels consecutive notes with inversion-equivalent interval-class numbers:

>>> pitch_numbers = [0, 25, 11, -4, -14, -13, 9, 10]
>>> notes = scoretools.make_notes(pitch_numbers, [(1, 4)])
>>> staff = Staff(notes)
>>> prototype = pitchtools.NumberedInversionEquivalentIntervalClass
>>> label(staff).with_intervals(prototype=prototype)
>>> override(staff).text_script.staff_padding = 4
>>> show(staff) 

Returns none.

LabelAgent.with_pitches(direction=Up, prototype=None)

Labels logical ties with pitches.

Example 1. Labels logical ties with pitch names:

>>> staff = Staff("<a d' fs'>4 g'4 ~ g'8 r8 fs''4")
>>> label(staff).with_pitches(prototype=None)
>>> override(staff).text_script.staff_padding = 4
>>> show(staff) 

Example 2. Labels logical ties with pitch numbers:

>>> staff = Staff("<a d' fs'>4 g'4 ~ g'8 r8 fs''4")
>>> prototype = pitchtools.NumberedPitch
>>> label(staff).with_pitches(prototype=prototype)
>>> override(staff).text_script.staff_padding = 4
>>> show(staff) 

Example 3. Labels logical ties with pitch-class numbers:

>>> staff = Staff("<a d' fs'>4 g'4 ~ g'8 r8 fs''4")
>>> prototype = pitchtools.NumberedPitchClass
>>> label(staff).with_pitches(prototype=prototype)
>>> override(staff).text_script.staff_padding = 4
>>> show(staff) 

Returns none.

LabelAgent.with_start_offsets(clock_time=False, direction=Up, font_size=None)

Labels logical ties with start offsets.

Example 1. Labels logical tie start offsets:

>>> staff = Staff(r"\times 2/3 { c'4 d'4 e'4 ~ } e'4 ef'4")
>>> label(staff).with_start_offsets(direction=Up)
>>> override(staff).text_script.staff_padding = 4
>>> override(staff).tuplet_bracket.staff_padding = 0
>>> show(staff) 

Example 2. Labels logical tie start offsets with clock time:

>>> staff = Staff(r"c'2 d' e' f'")
>>> score = Score([staff])
>>> attach(Tempo(Duration(1, 4), 60), staff[0])
>>> label(staff).with_start_offsets(clock_time=True)
>>> override(staff).text_script.staff_padding = 4
>>> override(staff).tuplet_bracket.staff_padding = 0
>>> show(score) 

Example 3. Labels logical tie start offsets with clock time and custom font size:

>>> staff = Staff(r"c'2 d' e' f'")
>>> score = Score([staff])
>>> attach(Tempo(Duration(1, 4), 60), staff[0])
>>> label(staff).with_start_offsets(
...     clock_time=True,
...     font_size=-3,
...     )
>>> override(staff).text_script.staff_padding = 4
>>> override(staff).tuplet_bracket.staff_padding = 0
>>> show(score) 

Returns none.

Special methods

(AbjadObject).__eq__(expr)

Is true when ID of expr equals ID of Abjad object. Otherwise false.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

Returns string.

(AbjadObject).__hash__()

Hashes Abjad object.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

(AbjadObject).__ne__(expr)

Is true when Abjad object does not equal expr. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.