Submodule style
- mscxyz.style.musical_symbol_font_faces
Musical symbol font faces
- mscxyz.style.musical_text_font_faces
Musical text font faces
- class mscxyz.style.Margin(even_top: 'float', odd_top: 'float', even_right: 'float', odd_right: 'float', even_bottom: 'float', odd_bottom: 'float', even_left: 'float', odd_left: 'float')[source]
Bases:
object- even_top: float
- odd_top: float
- even_right: float
- odd_right: float
- even_bottom: float
- odd_bottom: float
- even_left: float
- odd_left: float
- class mscxyz.style.Style(score: Score)[source]
Bases:
objectInterface specialized for the style manipulation.
- Parameters:
relpath – The relative (or absolute) path of a MuseScore file.
- property xml: XmlManipulator
- parent_element: _Element
The parent
/museScore/Score/Styleelement that contains all style tags.
- property styles: list[_Element]
Return all style elements (all XML elements inside the
<Style>) as a list.- Returns:
A list of all style elements.
- get_element(element_path: str) _Element[source]
Determines an lxml element that is a child to the
Styletag- Parameters:
element_path – see http://lxml.de/tutorial.html#elementpath
create – Create the element if not present in the parent
Styletag.
Example code:
# Set attributes on a maybe non-existent style tag. # <measureNumberOffset x="0.5" y="-2"/> test = Style('text.mscx') element = test.get_element('measureNumberOffset') element.attrib['x'] = '0.5' element.attrib['y'] = '-2' test.save()
- clean() None[source]
Remove the style, the layout breaks, the stem directions and the
font,b,i,pos,offsettags
- get(style_name: str, raise_exception: bool = True) str | None[source]
Get a style value by its style name (element path) of a style tag.
- Parameters:
style_name – see http://lxml.de/tutorial.html#elementpath
- set_attributes(style_name: str, attributes: dict[str, str | int | float]) _Element[source]
Set attributes on a style child tag.
- Parameters:
element_path – see http://lxml.de/tutorial.html#elementpath
- set(style_name: str | Sequence[str], value: str | int | float | dict[str, str | int | float] | None) list[tuple[str, str | int | float | dict[str, str | int | float] | None, str | int | float | dict[str, str | int | float] | None]][source]
Sets the value of an XML element identified by the given element path.
- Parameters:
style_name – A style name or multiple style names as a list or a element path expression. For more information, refer to http://lxml.de/tutorial.html#elementpath
value – The value to be set for the XML element. It can be a string, integer, or float.
- get_text_style(name: str) dict[str, str][source]
Get text styles as a dictonary. Only MuseScore2!
<Style> <TextStyle> <halign>center</halign> <valign>top</valign> <offsetType>absolute</offsetType> <name>Title</name> <family>MuseJazz</family> <size>28</size> <bold>1</bold> </TextStyle> </Style>
{ "halign": "center", "size": "28", "family": "MuseJazz", "bold": "1", "valign": "top", "name": "Title", "offsetType": "absolute", }
- Parameters:
name – The name of the text style, for example
Title,Subtitle,Lyricist,Fingering,String Number,Dynamicsetc.
- set_text_style(name: str, values: dict[str, str | int | float]) None[source]
Set text styles. Only MuseScore2!
- Parameters:
name – The name of the text style, for example
Title,Subtitle,Lyricist,Fingering,String Number,Dynamicsetc.values – A dictionary. The keys are the tag names, values are the text values of the child tags, for example
{size: 14, bold: 1}.
- get_all_fonts() list[tuple[str, str]][source]
Returns a list of tuples containing the tag name and the font face.
- set_text_fonts(new_font_face: str) list[tuple[str, str | int | float | dict[str, str | int | float] | None, str | int | float | dict[str, str | int | float] | None]][source]
Set the font face for nearly all font face related styles except for
romanNumeralFontFace,figuredBassFontFace,dynamicsFontFace,musicalSymbolFontandmusicalTextFont.Default values in v3 and v4:
lyricsOddFontFace: EdwinlyricsEvenFontFace: EdwinhairpinFontFace: EdwinpedalFontFace: EdwinchordSymbolAFontFace: EdwinchordSymbolBFontFace: EdwinromanNumeralFontFace: CampanianashvilleNumberFontFace: EdwinvoltaFontFace: EdwinottavaFontFace: EdwintupletFontFace: EdwindefaultFontFace: EdwintitleFontFace: EdwinsubTitleFontFace: EdwincomposerFontFace: EdwinlyricistFontFace: EdwinfingeringFontFace: EdwinlhGuitarFingeringFontFace: EdwinrhGuitarFingeringFontFace: EdwinstringNumberFontFace: EdwinharpPedalDiagramFontFace: EdwinharpPedalTextDiagramFontFace: EdwinlongInstrumentFontFace: EdwinshortInstrumentFontFace: EdwinpartInstrumentFontFace: EdwindynamicsFontFace: EdwinexpressionFontFace: EdwintempoFontFace: EdwintempoChangeFontFace: EdwinmetronomeFontFace: EdwinmeasureNumberFontFace: EdwinmmRestRangeFontFace: EdwintranslatorFontFace: EdwinsystemFontFace: EdwinstaffFontFace: EdwinrehearsalMarkFontFace: EdwinrepeatLeftFontFace: EdwinrepeatRightFontFace: EdwinframeFontFace: EdwintextLineFontFace: EdwinsystemTextLineFontFace: EdwinglissandoFontFace: EdwinbendFontFace: EdwinheaderFontFace: EdwinfooterFontFace: EdwininstrumentChangeFontFace: EdwinstickingFontFace: EdwinfiguredBassFontFace: MScoreBCuser1FontFace: Edwinuser2FontFace: Edwinuser3FontFace: Edwinuser4FontFace: Edwinuser5FontFace: Edwinuser6FontFace: Edwinuser7FontFace: Edwinuser8FontFace: Edwinuser9FontFace: Edwinuser10FontFace: Edwinuser11FontFace: Edwinuser12FontFace: EdwinletRingFontFace: EdwinpalmMuteFontFace: Edwin
- Parameters:
font_face – The new font face to be set.
- Returns:
A list of tuples representing the changes made. Each tuple contains the tag name, the old font face, and the new font face.
- set_title_fonts(font_face: str) list[tuple[str, str | int | float | dict[str, str | int | float] | None, str | int | float | dict[str, str | int | float] | None]][source]
- property musical_symbol_font: str | None
v3
<musicalSymbolFont>Leland</musicalSymbolFont> <dynamicsFontFace>Leland</dynamicsFontFace>
v4 // OBSOLETE after version 4.1. Dynamic text now takes its setting from expression.
<musicalSymbolFont>Leland</musicalSymbolFont> <dynamicsFont>Leland</dynamicsFont>
- property musical_text_font: str | None
<musicalTextFont>Leland Text</musicalTextFont>
- load_styles_as_string(styles: str) None[source]
Load styles into the XML tree and replace the old styles.
- Parameters:
styles – A string containing the XML style markup.
For example this inputs are valid:
Without declaration:
<pageWidth>8.27</pageWidth>
With declaration:
<?xml version="1.0"?> <museScore version="2.06"> <Style> <pageWidth>8.27</pageWidth>
- reload(save: bool = False) Style[source]
Reload the MuseScore file.
- Parameters:
save – Whether to save the changes before reloading. Default is False.
- Returns:
The reloaded Style object.
- See:
mscxyz.score.Score.reload()
- property page_width: float
The page width in
inch.<pageWidth>8.5</pageWidth>
- property page_height: float
The page height in
inch.<pageHeight>11.69</pageHeight>
- set_page_size(width: float | str, height: float | str) None[source]
Set the page size in
inch. At the same time, thepage_printable_widthattribute is set so that the margins do not change.- Parameters:
width – The page width in
inchas a float or a dimension string inmmorin.height – The page height in
inchas a float or a dimension string inmmorin.
- See:
- See:
- See:
Example
score.style.set_page_size("210mm", "297mm") # or: score.style.set_page_size(8.2677165354 , 11.6929133858)
- property page_even_top_margin: float
The top margin of the even pages in
inch.<pageEvenTopMargin>0.393701</pageEvenTopMargin>
- property page_odd_top_margin: float
The top margin of the odd pages in
inch.<pageOddTopMargin>0.393701</pageOddTopMargin>
- property page_even_right_margin: float
The top right of the even pages in
inch.<pageWidth>8.5</pageWidth> <pagePrintableWidth>7.7126</pagePrintableWidth> <pageEvenLeftMargin>0.393701</pageEvenLeftMargin>
- property page_odd_right_margin: float
The right margin of the odd pages in
inch.<pageWidth>8.5</pageWidth> <pagePrintableWidth>7.7126</pagePrintableWidth> <pageOddLeftMargin>0.393701</pageOddLeftMargin>
- property page_even_bottom_margin: float
The bottom margin of the even pages in
inch.<pageEvenBottomMargin>0.787403</pageEvenBottomMargin>
- property page_odd_bottom_margin: float
The bottom margin of the odd pages in
inch.<pageOddBottomMargin>0.787403</pageOddBottomMargin>
- property page_even_left_margin: float
The left margin of the even pages in
inch.<pageEvenLeftMargin>0.393701</pageEvenLeftMargin>
- property page_odd_left_margin: float
The left margin of the odd pages in
inch.<pageOddLeftMargin>0.393701</pageOddLeftMargin>
- property page_printable_width: float
The printable width of the page in
inch. This property is used to calculate the right margin.<pagePrintableWidth>7.7126</pagePrintableWidth>
- property margin: Margin | float
The margin of a page in
inch.<pagePrintableWidth>7.7126</pagePrintableWidth> <pageEvenLeftMargin>0.393701</pageEvenLeftMargin> <pageOddLeftMargin>0.393701</pageOddLeftMargin> <pageEvenTopMargin>0.393701</pageEvenTopMargin> <pageEvenBottomMargin>0.787403</pageEvenBottomMargin> <pageOddTopMargin>0.393701</pageOddTopMargin> <pageOddBottomMargin>0.787403</pageOddBottomMargin>
- property max_system_distance: float
The maximum system distance in
sp(staff space).<maxSystemDistance>15</maxSystemDistance>
- property show_header: bool
Show the header on the page.
<showHeader>1</showHeader>
- property header_first_page: bool
Show the header on the first page.
<headerFirstPage>1</headerFirstPage>
- property header_odd_even: bool
Use different headers for odd and even pages.
<headerOddEven>1</headerOddEven>
- property even_header_left: str | None
<evenHeaderL>$p</evenHeaderL>
- property even_header_center: str | None
<evenHeaderC></evenHeaderC>
- property even_header_right: str | None
<evenHeaderR></evenHeaderR>
- property odd_header_left: str | None
<oddHeaderL></oddHeaderL>
- property odd_header_center: str | None
<oddHeaderC></oddHeaderC>
- property odd_header_right: str | None
<oddHeaderR>$p</oddHeaderR>
- set_header_all(left: str, center: str, right: str) None[source]
Set the header for all pages.
- Parameters:
left – The left part of the header.
center – The center part of the header.
right – The right part of the header.
- See:
- See:
- See:
- See:
- See:
- See:
- set_header_odd_even(odd_left: str, even_left: str, odd_center: str, even_center: str, odd_right: str, even_right: str) None[source]
Set different headers for odd and even pages.
- See:
- See:
- See:
- See:
- See:
- See:
Show the footer on the page.
<showFooter>1</showFooter>
Show the footer on the first page.
<footerFirstPage>1</footerFirstPage>
Use different footers for odd and even pages.
<footerOddEven>1</footerOddEven>
<evenFooterL></evenFooterL>
<evenFooterC>$C</evenFooterC>
<evenFooterR></evenFooterR>
<oddFooterL></oddFooterL>
<oddFooterC>$C</oddFooterC>
<oddFooterR></oddFooterR>
Set the footer for all pages.
- Parameters:
left – The left part of the footer.
center – The center part of the footer.
right – The right part of the footer.
- See:
- See:
- See:
- See:
- See:
- See:
Set the footer for odd and even pages.
- See:
- See:
- See:
- See:
- See:
- See:
- property staff_space: float | None
The staff space in
mm, default values are1.750mm=0.069in<Spatium>1.74978</Spatium>
styledef.cpp#L640 default 24.8 ???
- reset_small_staffs() None[source]
Reset all small staffs to normal size.
<Part id="1"> <Staff id="1"> <StaffType group="pitched"> <name>stdNormal</name> <small>1</small> </StaffType> </Staff> <trackName>Voice</trackName> <Instrument id="voice"> <trackName>Voice</trackName> <minPitchP>36</minPitchP> <maxPitchP>94</maxPitchP>
- property lyrics_font_size: float
- property lyrics_min_distance: float | None
default: 0.25