abjad.wrapper

abjad.wrapper.Wrapper(*[, annotation, ...])

Wrapper.

class abjad.wrapper.Wrapper(*, annotation: str | None = None, check_duplicate_indicator: bool = False, component: Component | None = None, context_name: str | None = None, deactivate: bool = False, direction: Vertical | str | None = None, hide: bool = False, indicator: Any = None, synthetic_offset: Offset | None = None, tag: Tag = Tag(string=''))[source]

Wrapper.

Use abjad.get.attach() to attach an indicator to a component.

Use abjad.get.wrapper() to inspect the wrapper that is created.

>>> component = abjad.Note("c'4")
>>> articulation = abjad.Articulation("accent")
>>> abjad.attach(articulation, component, direction=abjad.UP)
>>> wrapper = abjad.get.wrapper(component)
>>> type(wrapper)
<class 'abjad.wrapper.Wrapper'>

annotation()

Gets annotation with which indicator is attached to component.

component()

Gets component to which indicator is attached.

context_name()

Gets name of context at which indicator is attached to component.

deactivate()

Is true when indicator is deactivated in LilyPond output.

direction()

Gets direction of indicator.

hide()

Is true when indcator does not appear in LilyPond output.

indicator()

Gets indicator.

is_bundled()

Is true when indicator is bundled.

leaked_start_offset()

Gets start offset and checks to see whether indicator leaks to the right.

set_deactivate(argument)

Sets wrapper deactivate flag.

set_tag(argument)

Sets wrapper tag.

site_adjusted_start_offset()

Gets site-adjusted start offset.

start_offset()

Gets start offset.

synthetic_offset()

Gets synthetic offset.

tag()

Gets wrapper tag.

unbundle_indicator()

Unbundles indicator.

annotation() str | None[source]

Gets annotation with which indicator is attached to component.

component() Component | None[source]

Gets component to which indicator is attached.

context_name() str | None[source]

Gets name of context at which indicator is attached to component.

deactivate() bool[source]

Is true when indicator is deactivated in LilyPond output.

direction()[source]

Gets direction of indicator.

hide() bool[source]

Is true when indcator does not appear in LilyPond output.

indicator() Any[source]

Gets indicator.

is_bundled() bool[source]

Is true when indicator is bundled.

leaked_start_offset() Offset[source]

Gets start offset and checks to see whether indicator leaks to the right. This is either the wrapper’s synthetic offset (if set); or the START offset of the wrapper’s component (if indicator DOES NOT leak); or else the STOP offset of the wrapper’s component (if indicator DOES leak).

Start- and stop-text-spans attach to the same leaf. But stop-text-span leaks to the right:

>>> voice = abjad.Voice("c'2 d'2")
>>> start_text_span = abjad.StartTextSpan()
>>> abjad.attach(start_text_span, voice[0])
>>> stop_text_span = abjad.StopTextSpan(leak=True)
>>> abjad.attach(stop_text_span, voice[0])
>>> abjad.show(voice)  
>>> string = abjad.lilypond(voice)
>>> print(string)
\new Voice
{
    c'2
    \startTextSpan
    <>
    \stopTextSpan
    d'2
}

Start offset and leaked start offset are the same for start-text-span:

>>> wrapper = abjad.get.wrapper(voice[0], abjad.StartTextSpan)
>>> wrapper.start_offset(), wrapper.leaked_start_offset()
(Offset((0, 1)), Offset((0, 1)))

Start offset and leaked start offset differ for stop-text-span:

>>> wrapper = abjad.get.wrapper(voice[0], abjad.StopTextSpan)
>>> wrapper.start_offset(), wrapper.leaked_start_offset()
(Offset((0, 1)), Offset((1, 2)))
set_deactivate(argument: bool) None[source]

Sets wrapper deactivate flag.

set_tag(argument: Tag) None[source]

Sets wrapper tag.

site_adjusted_start_offset() Offset[source]

Gets site-adjusted start offset. Indicators with site equal to absolute_after, after or closing give a site-adjusted start offset equal to the stop offset of the wrapper’s component. Indicators with any other site give a site-adjusted start offset equal to the start offset of the wrapper’s component. This is the usual case, and means that site-adjusted start offset equals vanilla start offset. But if synthetic_offset is set then synthetic_offset is returned directly without examining the format site at all.

>>> staff = abjad.Staff("c'4")
>>> abjad.attach(abjad.Ottava(-1, site="before"), staff[0])
>>> abjad.attach(abjad.Ottava(0, site="after"), staff[0])
>>> for wrapper in abjad.get.wrappers(staff[0], abjad.Ottava):
...     wrapper.indicator(), wrapper.site_adjusted_start_offset()
... 
(Ottava(n=-1, site='before'), Offset((0, 1)))
(Ottava(n=0, site='after'), Offset((1, 4)))
start_offset() Offset[source]

Gets start offset. This is either the wrapper’s synthetic offset or the start offset of the wrapper’s component.

synthetic_offset() Offset | None[source]

Gets synthetic offset.

tag() Tag[source]

Gets wrapper tag.

unbundle_indicator() Any[source]

Unbundles indicator.