tweaks¶
Classes
Bundled indicator. |
|
Tweak. |
- class abjad.tweaks.Bundle(indicator, tweaks=())[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 5, in __init__ File "/Users/trevor/abjad/abjad/tweaks.py", line 89, 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)[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', tag=None)
>>> bundle.get_attribute("style") is None True
- remove(tweak)[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=())
>>> bundle_3 = abjad.bundle(bundle_2, r"- \tweak color #blue") >>> bundle_3.tweaks (Tweak(string='- \\tweak color #blue', tag=None),)
- Return type:
- class abjad.tweaks.Tweak(string, tag=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).
- rtype:
- rtype:
- rtype:
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, *tweaks, tag=None, overwrite=False)[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 302, in bundle raise Exception(message) Exception: duplicate 'color' attribute: Tweak(string='- \\tweak color #blue', tag=None) Tweak(string='- \\tweak color #red', 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', 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 316, in bundle raise Exception(message) Exception: duplicate 'color' attribute: OLD: Tweak(string='- \\tweak color #blue', tag=None) NEW: Tweak(string='- \\tweak color #red', 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', tag=None)
- Return type: