From 58f8fcfb15531fc052f9cdd02543cafe93428698 Mon Sep 17 00:00:00 2001 From: pin Date: Mon, 8 Feb 2010 10:14:02 +0000 Subject: [PATCH] =?utf8?q?xtreme=20programming=20step1=20:=20gestion=20des?= =?utf8?q?=20fichiers=20xml=20dans=20la=20bo=C3=AEte=20de=20dialogue=20d'o?= =?utf8?q?uverture.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@11 fe552daf-6dbe-4428-90eb-1537e0879342 --- .pydevproject | 2 +- .settings/org.eclipse.core.resources.prefs | 4 +++- src/gui/MINWiiDialog.py | 6 ++++++ src/gui/PGUConfiguration.py | 19 +++++++++++++------ src/songs/musicxmltosong.py | 11 +++++++---- 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/.pydevproject b/.pydevproject index e35390d..ed4bea1 100755 --- a/.pydevproject +++ b/.pydevproject @@ -3,7 +3,7 @@ -/MINWiiV7/src +/MINWii-pinbe/src python 2.6 Default diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 6a3e2eb..abf067d 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,5 +1,6 @@ -#Mon Dec 07 03:31:40 CET 2009 +#Mon Feb 08 10:43:31 CET 2010 eclipse.preferences.version=1 +encoding//src/gui/MINWiiDialog.py=utf-8 encoding//src/mxmMidi/DataTypeConverters.py=ISO-8859-1 encoding//src/mxmMidi/EventDispatcher.py=ISO-8859-1 encoding//src/mxmMidi/MidiFileParser.py=ISO-8859-1 @@ -12,3 +13,4 @@ encoding//src/mxmMidi/RawInstreamFile.py=ISO-8859-1 encoding//src/mxmMidi/RawOutstreamFile.py=ISO-8859-1 encoding//src/mxmMidi/__init__.py=ISO-8859-1 encoding//src/mxmMidi/constants.py=ISO-8859-1 +encoding//src/songs/musicxmltosong.py=utf-8 diff --git a/src/gui/MINWiiDialog.py b/src/gui/MINWiiDialog.py index 51e51af..4116318 100644 --- a/src/gui/MINWiiDialog.py +++ b/src/gui/MINWiiDialog.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- ''' Created on 17 dec. 2009 @@ -53,6 +54,11 @@ class MINWiiDialog(pguGui.FileDialog): else : label = pguGui.basic.Label(key,font = self.customFont) self.list.add(label,value=i) + elif i.endswith(".xml") : + # TODO : afficher le Titre de la chanson au lieu du nom + # de fichier + label = pguGui.basic.Label(i, font=self.customFont) + self.list.add(label,value=i) #self.list.resize() self.list.set_vertical_scroll(0) #self.list.repaintall() diff --git a/src/gui/PGUConfiguration.py b/src/gui/PGUConfiguration.py index 631932c..214a347 100644 --- a/src/gui/PGUConfiguration.py +++ b/src/gui/PGUConfiguration.py @@ -24,6 +24,7 @@ from cursor.WarpingCursor import * from controllers.Wiimote import Wiimote from logging.Log import Log from songs.Song import Song,loadSong +from songs.musicxmltosong import musicXml2Song from constants import * from MINWiiDialog import MINWiiDialog @@ -102,12 +103,17 @@ class PGUConfiguration(pguGui.Desktop): if dlg.value: if os.path.isfile(dlg.value): self.file = dlg.value - self.song = loadSong(self.file) - key = os.path.basename(self.file)[:-5] - if key in reversedReadabilityDict : - label = self.createLabel(reversedReadabilityDict[key]) - else : - label = self.createLabel(key) + if self.file.endswith('.smwi') : + self.song = loadSong(self.file) + key = os.path.basename(self.file)[:-5] + if key in reversedReadabilityDict : + label = self.createLabel(reversedReadabilityDict[key]) + else : + label = self.createLabel(key) + elif self.file.endswith('.xml') : + self.song = musicXml2Song(self.file, printNotes=True) + filename = os.path.basename(self.file) + label = self.createLabel(filename) self.browseButton = pguGui.Button(label) self.browseButton.connect(pguGui.CLICK, self.open_file_browser, None) if not self.songSwitch.value : @@ -115,6 +121,7 @@ class PGUConfiguration(pguGui.Desktop): self.mainTable.clear() self.fillMainTable() + def fillMainTable(self): self.mainTable.tr() diff --git a/src/songs/musicxmltosong.py b/src/songs/musicxmltosong.py index 0d4bb99..39df188 100755 --- a/src/songs/musicxmltosong.py +++ b/src/songs/musicxmltosong.py @@ -9,7 +9,7 @@ import sys from types import StringTypes from xml.dom.minidom import parse from optparse import OptionParser -from Song import Song +#from Song import Song # Do4 <=> midi 60 OCTAVE_REF = 4 @@ -192,7 +192,7 @@ def _getNodeValue(node, path, default=_marker) : else : return default -def musicXml2Song(input, output, partIndex=0, printNotes=False) : +def musicXml2Song(input, partIndex=0, printNotes=False) : if isinstance(input, StringTypes) : input = open(input, 'r') @@ -209,6 +209,9 @@ def musicXml2Song(input, output, partIndex=0, printNotes=False) : if printNotes : part.pprint() + + return part + # divisions de la noire # divisions = 0 @@ -245,10 +248,10 @@ def main() : options, args = op.parse_args() - if len(args) != 2 : + if len(args) != 1 : raise SystemExit(op.format_help()) - musicXml2Song(args[0], args[1], partIndex=options.partIndex, printNotes=options.printNotes) + musicXml2Song(args[0], partIndex=options.partIndex, printNotes=options.printNotes) -- 2.20.1