"""
import pygame
+import os.path
pygame.font.init()
+
# playingscreen
FRAMERATE = 50
BORDER = 0 # 5px
FONT = pygame.font.Font(None, 80)
FONT_COLOR = (0,0,0)
DEFAULT_MIDI_VELOCITY = 96
+
+SONG_FILE_PATH = '../../chansons'
+
+# cuisine : ne pas modifier
+_here = os.path.abspath(__file__).split(os.path.sep)[:-1]
+SONG_FILE_PATH = SONG_FILE_PATH.split('/')
+SONG_FILE_PATH = _here + SONG_FILE_PATH
+SONG_FILE_PATH = os.path.abspath(os.path.sep.join(SONG_FILE_PATH))
+
+
from synth import Synth
from eventutils import EventDispatcher
from musicxml import musicXml2Song
+from config import SONG_FILE_PATH
class MinWii(object):
synth.program_select(0, 0, 0)
if True :
- #home = Home()
- #home.connect(QUIT, app.quit)
- #app.run(home)
- #app.close(home)
+ home = Home(songPath=SONG_FILE_PATH)
+ home.connect(QUIT, app.quit)
+ app.run(home)
+ app.close(home)
song = musicXml2Song('/Users/pinbe/dev/minwii/src/songs/chansons/etoile_neige.xml', printNotes=True)
playingScreen = SongPlayingScreen(synth, song)
from pgu.gui import QUIT
import pygame
from gui.constants import reversedReadabilityDict, modeDict
+from songfilebrowser import FileOpenDialog
class Home(Table) :
"""
def __init__(self,**params):
Table.__init__(self,**params)
+ self.songPath = params.get('songPath', '.')
self.spaceSize = (100,100)
self.font = pygame.font.Font(None,70)
self._fill()
self.td(Spacer(500,500))
def _initLocalListeners(self) :
+ self.browseButton.connect(CLICK, self.open_file_browser)
self.quitButton.connect(CLICK, self._exitHome)
def _exitHome(self, data=None) :
w,h = self.font.size(text)
label = Label(text,width=w,height=h,font = font)
return(label)
-
+
+ def open_file_browser(self):
+ dlg = FileOpenDialog(self.songPath)
+ #d = MINWiiDialog(font = self.font,width = 800, height = 600,path = "../songs/smwis")
+ #d.connect(pguGui.CHANGE, self.handle_file_browser_closed, d)
+ dlg.open()
+
\ No newline at end of file
--- /dev/null
+# -*- coding: utf-8 -*-
+"""
+Boîte de dialogue pour sélection des chansons.
+
+$Id$
+$URL$
+"""
+
+from pgu.gui import FileDialog
+import os
+
+class FileOpenDialog(FileDialog):
+
+
+
+ def __init__(self, path):
+ FileDialog.__init__(self,
+ title_txt="Ouvrir une chanson",
+ button_txt="Ouvrir",
+ #cls="dialog",
+ #folderText = "Folder",
+ #fileText = "File",
+ path=path,
+ #customFont = None,
+ showCurDir = False
+ #customWidth = 350,
+ #customHeight = 150
+ )
+
+ def _list_dir_(self):
+ self.input_dir.value = self.curdir
+ self.input_dir.pos = len(self.curdir)
+ self.input_dir.vpos = 0
+ dirs = []
+ files = []
+ try:
+ for i in os.listdir(self.curdir):
+ if os.path.isdir(os.path.join(self.curdir, i)): dirs.append(i)
+ else: files.append(i)
+ except:
+ self.input_file.value = "Opps! no access"
+ #if '..' not in dirs: dirs.append('..')
+ dirs.sort()
+ dirs = ['..'] + dirs
+
+ files.sort()
+ for i in dirs:
+ if i.startswith('.') and i != '..' :
+ continue
+ #item = ListItem(image=self.dir_img, text=i, value=i)
+ if self.customFont == None :
+ self.list.add(i,image=self.dir_img,value=i)
+ else :
+ label = basic.Label(i,font = self.customFont)
+ self.list.add(label,image=self.dir_img,value=i)
+ for i in files:
+ #item = ListItem(image=None, text=i, value=i)
+ if i.startswith('.') or (not i.endswith('.xml')) :
+ continue
+ if self.customFont == None :
+ self.list.add(i,value=i)
+ else:
+ label = basic.Label(i,font = self.customFont)
+ self.list.add(label,value=i)
+ #self.list.resize()
+ self.list.set_vertical_scroll(0)
+ #self.list.repaintall()
+