tweaks
Classes
Bundled indicator. |
|
Tweak. |
- class abjad.tweaks.Bundle(indicator: Any, tweaks: tuple[Tweak, ...] = (), comment: str | None = None)[source]
Bundled indicator.
Raises exception on duplicate attributes:
>>> abjad.Bundle( ... indicator=abjad.Articulation("."), ... tweaks=( ... abjad.Tweak(r"- \tweak color #blue"), ... abjad.Tweak(r"- \tweak color #red"), ... ), ... ) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<string>", line 6, in __init__ File "/Users/trevor/abjad/abjad/tweaks.py", line 93, in __post_init__ raise Exception(f"duplicate {attribute!r} attribute.") Exception: duplicate 'color' attribute.
Attributes Summary
Implement delattr(self, name).
Return self==value.
Return self>=value.
Return self>value.
Return hash(self).
Return self<=value.
Return self<value.
Return repr(self).
Implement setattr(self, name, value).
Gets tweak with
attribute
.Removes
tweak
from bundle and returns new bundle.Special methods
- overridden __delattr__(name)
Implement delattr(self, name).
- overridden __eq__(other)
Return self==value.
- overridden __ge__(other)
Return self>=value.
- overridden __gt__(other)
Return self>value.
- overridden __hash__()
Return hash(self).
- overridden __le__(other)
Return self<=value.
- overridden __lt__(other)
Return self<value.
- overridden __repr__()
Return repr(self).
- overridden __setattr__(name, value)
Implement setattr(self, name, value).
Methods
- get_attribute(attribute: str) Tweak | None [source]
Gets tweak with
attribute
.>>> markup = abjad.Markup(r"\markup Allegro") >>> bundle = abjad.bundle( ... markup, ... r"- \tweak color #red", ... r"- \tweak font-size 3", ... ) >>> bundle.get_attribute("color") Tweak(string='- \\tweak color #red', i=None, tag=None)
>>> bundle.get_attribute("style") is None True
- remove(tweak: Tweak) Bundle [source]
Removes
tweak
from bundle and returns new bundle.>>> markup = abjad.Markup(r"\markup Allegro") >>> bundle_1 = abjad.bundle(markup, r"- \tweak color #red") >>> tweak = bundle_1.get_attribute("color")
>>> bundle_2 = bundle_1.remove(tweak) >>> bundle_2 Bundle(indicator=Markup(string='\\markup Allegro'), tweaks=(), comment=None)
>>> bundle_3 = abjad.bundle(bundle_2, r"- \tweak color #blue") >>> bundle_3.tweaks (Tweak(string='- \\tweak color #blue', i=None, tag=None),)
- class abjad.tweaks.Tweak(string: str, i: int | None = None, tag: Tag | None = None)[source]
Tweak.
Attributes Summary
Implement delattr(self, name).
Return self==value.
Return self>=value.
Return self>value.
Return hash(self).
Return self<=value.
Return self<value.
Return repr(self).
Implement setattr(self, name, value).
Special methods
- overridden __delattr__(name)
Implement delattr(self, name).
- overridden __eq__(other)
Return self==value.
- overridden __ge__(other)
Return self>=value.
- overridden __gt__(other)
Return self>value.
- overridden __hash__()
Return hash(self).
- overridden __le__(other)
Return self<=value.
- overridden __lt__(other)
Return self<value.
- overridden __repr__()
Return repr(self).
- overridden __setattr__(name, value)
Implement setattr(self, name, value).
Methods
Functions
Bundles |
|
Appends |
- abjad.tweaks.bundle(indicator: Any, *tweaks: str | Tweak, comment: str | None = None, overwrite: bool = False, tag: Tag | None = None) Bundle [source]
Bundles
indicator
withtweaks
.Bundles indicator:
>>> staff = abjad.Staff("c'4 d' e' f'") >>> bundle = abjad.bundle( ... abjad.Articulation("."), ... r"- \tweak color #red", ... ) >>> abjad.attach(bundle, staff[0]) >>> abjad.show(staff)
Bundles existing bundle:
>>> staff = abjad.Staff("c'4 d' e' f'") >>> bundle = abjad.bundle(abjad.Articulation("."), r"- \tweak color #red") >>> bundle = abjad.bundle(bundle, r"- \tweak font-size 3") >>> abjad.attach(bundle, staff[0]) >>> abjad.show(staff)
Raises exception on duplicate attribute:
>>> bundle = abjad.bundle( ... abjad.Articulation("."), ... r"- \tweak color #blue", ... r"- \tweak color #red", ... ) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/trevor/abjad/abjad/tweaks.py", line 310, in bundle raise Exception(message) Exception: duplicate 'color' attribute: Tweak(string='- \\tweak color #blue', i=None, tag=None) Tweak(string='- \\tweak color #red', i=None, tag=None)
Unless
overwrite=True
:>>> bundle = abjad.bundle( ... abjad.Articulation("."), ... r"- \tweak color #blue", ... r"- \tweak color #red", ... overwrite=True, ... ) >>> for _ in bundle.tweaks: ... _ ... Tweak(string='- \\tweak color #red', i=None, tag=None)
Also raises exception on duplicate attribute:
>>> bundle = abjad.bundle( ... abjad.Articulation("."), ... r"- \tweak color #blue", ... ) >>> bundle = abjad.bundle( ... bundle, ... r"- \tweak color #red", ... ) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/trevor/abjad/abjad/tweaks.py", line 324, in bundle raise Exception(message) Exception: duplicate 'color' attribute: OLD: Tweak(string='- \\tweak color #blue', i=None, tag=None) NEW: Tweak(string='- \\tweak color #red', i=None, tag=None)
Unless
overwrite=True
:>>> bundle = abjad.bundle( ... abjad.Articulation("."), ... r"- \tweak color #blue", ... ) >>> bundle = abjad.bundle( ... bundle, ... r"- \tweak color #red", ... overwrite=True, ... ) >>> for _ in bundle.tweaks: ... _ ... Tweak(string='- \\tweak color #red', i=None, tag=None)