# -*- coding: ISO-8859-1 -*- """ capellaScript -- Copyright (c) 2003 Peter Becker >>> LayoutFix Korrigiert das durch einen Capella Fehler zerstörte Layout || Ursache : 2 x Script dann Undo, und das Layout ist zerstört <<< History: 07.05.04 - Erste Version 07.06.04 - Balkensteigung aufgenommen """ from xml.dom.minidom import NodeList def changeDoc(score): global formatTyp bf = score.getElementsByTagName('beamFlattening') if formatTyp == 0: bf[0].setAttribute('from','49') bf[0].setAttribute('to','29') bf[0].setAttribute('fromMax','148') bf[0].setAttribute('toMax','55') elif formatTyp == 1: bf[0].setAttribute('from','0') bf[0].setAttribute('to','0') bf[0].setAttribute('fromMax','34') bf[0].setAttribute('toMax','34') elif formatTyp == 2: bf[0].setAttribute('from','18') bf[0].setAttribute('to','18') bf[0].setAttribute('fromMax','119') bf[0].setAttribute('toMax','84') elif formatTyp == 3: bf[0].setAttribute('from','18') bf[0].setAttribute('to','9') bf[0].setAttribute('fromMax','119') bf[0].setAttribute('toMax','21') if formatTyp == 4: bf[0].setAttribute('from','0') bf[0].setAttribute('to','0') bf[0].setAttribute('fromMax','173') bf[0].setAttribute('toMax','0') sp = score.getElementsByTagName('spacing') sp[0].setAttribute('rel','75') sp[0].setAttribute('abs','16') if sp[0].hasAttribute('useRealSize'): sp[0].removeAttribute('useRealSize') if sp[0].hasAttribute('allowCompression'): sp[0].removeAttribute('allowCompression') if sp[0].hasAttribute('useLyricsSize'): sp[0].removeAttribute('useLyricsSize') # Hauptprogramm: from caplib.capDOM import ScoreChange import tempfile class ScoreChange(ScoreChange): def changeScore(self, score): changeDoc(score) def saDialog(): global formatTyp options = ScriptOptions() opt = options.get() placeholder1 = Label(' ',width=1) placeholder2 = Label(' ',width=1) placeholder3 = Label(' ',width=1) placeholder4 = Label(' ',width=1) radFormatTyp = Radio(['Standard','Capella2','klassisch','modern','waagrecht'],text='Format auswählen',value=int(opt.get('Balkensteigung','0'))) subboxFormat = HBox([radFormatTyp,placeholder2],padding=4) mainboxFormat = VBox([subboxFormat],text='Balkensteigung') box = VBox([mainboxFormat,placeholder1],padding=1) dlg = Dialog('LayoutFix', box) if dlg.run(): formatTyp = radFormatTyp.value() options.set(opt) return True else: return False # Hauptprogramm: if activeScore(): if saDialog(): activeScore().registerUndo("LayoutFix") tempInput = tempfile.mktemp('.capx') tempOutput = tempfile.mktemp('.capx') activeScore().write(tempInput) ScoreChange(tempInput, tempOutput) activeScore().read(tempOutput) os.remove(tempInput) os.remove(tempOutput)