musicscore.layout

class musicscore.layout.Margins(parent: PageLayout | SystemLayout, left: float | int = None, right: float | int = None, top: float | int = None, bottom: float | int = None)[source]

Bases: object

property bottom

Set and get XMLBottomMargin value of parent.

property left: int | float

Set and get XMLLeftMargin value of parent.

property parent
Returns:

parent layout object. PageLayout and SystemLayout are implemented.

property right: int | float

Set and get XMLRightMargin value of parent.

property top: int | float

Set and get XMLTopMargin value of parent.

class musicscore.layout.PageLayout(size: str = 'A4', orientation: str = 'portrait')[source]

Bases: XMLWrapper, LayoutMixin

Parameters:
  • sizePAGE_SIZES

  • orientation – ‘portrait’, ‘landscape’

XMLClass

alias of XMLPageLayout

to_string(*args, **kwargs) str

XMLWrapper method

Calls to_string method of self.xml_object

Returns:

musicxml snippet

property margins: Margins

Gets margins attribute.

Returns:

margins object

Return type:

Margins

property orientation: str

Set and get orientation. Permitted values are [‘portrait’, ‘landscape’]. After setting value, if parent and size already exist, page’s height and width are set.

Returns:

‘portrait’, ‘landscape’

Return type:

str

property parent
Returns:

musicscore object which uses this layout object.

Todo

Print implementation: At this moment only Score is implemented.

property scaling: Scaling
Returns:

Score’s Scaling.

Return type:

Scaling

property size: str

Set and get orientation. Permitted values are keys of obj:PAGE_SIZES. After setting value, if parent and orientation already exist, page’s height and width are set.

Returns:

sizes in PAGE_SIZES

Return type:

str

property xml_object: XMLElement

XMLWrapper method

This musicscore class has an equivalent MusicXML class which can be reached via this property.

If an attribute is not found directly in the main class, it wll be passed on to __get_attribute__ or __set__attribute__ methods of self.xml_object. It can also use the short cut attributes of XMLElement to get or set the first child.

Returns:

wrapped MusicXML element of type XMLClass

class musicscore.layout.Scaling(millimeters: int | float = 7.2319, tenths: int | float = 40)[source]

Bases: XMLWrapper

XMLClass

alias of XMLScaling

millimeters_to_tenths(x: int | float) int | float[source]

Converts millimeter value into tenths

Parameters:

x – millimeters

Returns:

calculated tenths

to_string(*args, **kwargs) str

XMLWrapper method

Calls to_string method of self.xml_object

Returns:

musicxml snippet

property millimeters: int | float

Set and get millimeters value of scaling object. After setting value, parent Score’s PageLayout is updated to reflect the changes.

Returns:

millimeters

Return type:

Union[int, float]

property score

Set and get parent Score. After setting score, its XMLScaling and XMLDefaults are created if needed.

Returns:

parent score

Return type:

Score

property tenths: int | float

Set and get tenths value of scaling object. After setting value, parent Score’s PageLayout is updated to reflect the changes.

Returns:

tenths

Return type:

Union[int, float]

property xml_object: XMLElement

XMLWrapper method

This musicscore class has an equivalent MusicXML class which can be reached via this property.

If an attribute is not found directly in the main class, it wll be passed on to __get_attribute__ or __set__attribute__ methods of self.xml_object. It can also use the short cut attributes of XMLElement to get or set the first child.

Returns:

wrapped MusicXML element of type XMLClass

class musicscore.layout.StaffLayout(staff_distance=80)[source]

Bases: XMLWrapper, LayoutMixin

XMLClass

alias of XMLStaffLayout

to_string(*args, **kwargs) str

XMLWrapper method

Calls to_string method of self.xml_object

Returns:

musicxml snippet

property parent
Returns:

musicscore object which uses this layout object.

Todo

Print implementation: At this moment only Score is implemented.

property staff_distance: int | float | None

Set and get value_ of XMLStaffDistance.

Returns:

self.xml_object.xml_staff_distance.value_

Return type:

int, float, None

property xml_object: XMLElement

XMLWrapper method

This musicscore class has an equivalent MusicXML class which can be reached via this property.

If an attribute is not found directly in the main class, it wll be passed on to __get_attribute__ or __set__attribute__ methods of self.xml_object. It can also use the short cut attributes of XMLElement to get or set the first child.

Returns:

wrapped MusicXML element of type XMLClass

class musicscore.layout.SystemLayout(system_distance: int | float = 117, top_system_distance: int | float = 117)[source]

Bases: XMLWrapper, LayoutMixin

XMLClass

alias of XMLSystemLayout

to_string(*args, **kwargs) str

XMLWrapper method

Calls to_string method of self.xml_object

Returns:

musicxml snippet

property margins: Margins

Gets margins attribute.

Returns:

margins object

Return type:

Margins

property parent
Returns:

musicscore object which uses this layout object.

Todo

Print implementation: At this moment only Score is implemented.

property system_distance: int | float | None

Set and get value of XMLSystemDistance.

Returns:

self.xml_object.xml_system_distance.value_

Return type:

int, float, None

property top_system_distance: int | float | None

Set and get value of XMLTopSystemDistance.

Returns:

self.xml_object.xml_top_system_distance.value_

Return type:

int, float, None

property xml_object: XMLElement

XMLWrapper method

This musicscore class has an equivalent MusicXML class which can be reached via this property.

If an attribute is not found directly in the main class, it wll be passed on to __get_attribute__ or __set__attribute__ methods of self.xml_object. It can also use the short cut attributes of XMLElement to get or set the first child.

Returns:

wrapped MusicXML element of type XMLClass

musicscore.layout.PAGE_MARGINS = {'A3': {'landscape': {'bottom': 70, 'left': 111, 'right': 70, 'top': 70}, 'portrait': {'bottom': 70, 'left': 111, 'right': 70, 'top': 70}}, 'A4': {'landscape': {'bottom': 70, 'left': 111, 'right': 70, 'top': 70}, 'portrait': {'bottom': 70, 'left': 140, 'right': 70, 'top': 70}}}
musicscore.layout.PAGE_SIZES = {'A3': (297.0389, 419.9819), 'A4': (209.991, 297.0389)}
musicscore.layout.SCALING = {'millimeters': 7.2319, 'tenths': 40}
musicscore.layout.STAFF_LAYOUT = {'staff_distance': 80}
musicscore.layout.SYSTEM_LAYOUT = {'system_distance': 117, 'top_system_distance': 117}
musicscore.layout.SYSTEM_MARGINS = {'left': 0, 'right': 0}