scamp.text.StaffText

class scamp.text.StaffText(text: str, italic: bool = False, bold: bool = False, placement: str = 'above')[source]

Bases: SavesToJSON, NoteProperty

Represents text that will be attached to the staff at a given note. Place this object in the fourth properties argument of play_note(), either alone, or under the “text” key.

Parameters:
  • text – the text to display

  • italic – whether or not to make text italic

  • bold – whether or not to make text bold

  • placement – placement relative to the staff; either “above” of “below”

Variables:
  • text – the text to display

  • italic – whether or not to make text italic

  • bold – whether or not to make text bold

  • placement – placement relative to the staff; either “above” of “below”

Methods

from_string(string)

Interprets a string as a staff text.

to_abjad()

Converts this to an abjad Markup object.

to_pymusicxml()

Converts this to a pymusicxml TextAnnotation object.

Inherited Methods

duplicate()

Returns a copy of this object by serializing to and from JSON.

json_dumps()

Dump this object as a JSON string.

json_loads(s)

Load this object from a JSON string.

load_from_json(file_path)

Load this object from a JSON file with the given path.

save_to_json(file_path)

Save this object to a JSON file using the given path.

classmethod from_string(string: str)[source]

Interprets a string as a staff text. For now, it just looks for 1, 2, or 3 leading and trailing asterisks or underscores to make the whole text italic, bold or bold-italic respectively. (This only works on the whole text.)

Parameters:

string – the text, possible with leading and trailing asterisks/underscores

to_pymusicxml() TextAnnotation[source]

Converts this to a pymusicxml TextAnnotation object.

to_abjad() abjad.Markup[source]

Converts this to an abjad Markup object.

duplicate() T

Returns a copy of this object by serializing to and from JSON.

json_dumps() str

Dump this object as a JSON string. This uses a custom encoder that recognizes and appropriately converts any attributes that are object inheriting from SavesToJSON.

classmethod json_loads(s: str) T

Load this object from a JSON string. This uses a custom decoder that looks for a “_type” key in any object/dictionary being parsed and converts it to the class specified (assuming it a subclass of SavesToJSON).

Parameters:

s – a string representing this object in JSON format

classmethod load_from_json(file_path: str) T

Load this object from a JSON file with the given path. This uses a custom decoder that looks for a “_type” key in any object/dictionary being parsed and converts it to the class specified (assuming it a subclass of SavesToJSON).

Parameters:

file_path – path for loading the file

save_to_json(file_path: str) None

Save this object to a JSON file using the given path. This uses a custom encoder that recognizes and appropriately converts any attributes that are object inheriting from SavesToJSON.

Parameters:

file_path – path for saving the file