X-Git-Url: https://scm.cri.mines-paristech.fr/git/minwii.git/blobdiff_plain/832d3600014a2e21565964fb8e5e39192c6640d1..1ba1c6642bcd08f1fde82e6b0d99927346df752b:/src/minwii/widgets/home.py diff --git a/src/minwii/widgets/home.py b/src/minwii/widgets/home.py index 18e1c6f..429342b 100755 --- a/src/minwii/widgets/home.py +++ b/src/minwii/widgets/home.py @@ -21,15 +21,20 @@ from minwii.globals import PLAYING_MODES from songfilebrowser import FileOpenDialog import os.path -STYLE_LEFT_COL = {'border_right' : 2, - 'border_left' : 2, - 'align' : 1} -STYLE_RIGHT_COL = {'border_right' : 2, - 'border_left' : 2, - 'align' : -1} +STYLE_LEFT_COL = {#'border_right' : 2, + #'border_left' : 2, + 'align' : 1, + 'padding_top' : 30, + 'padding_right' : 10} +STYLE_RIGHT_COL = {#'border_right' : 2, + #'border_left' : 2, + 'align' : -1, + 'padding_top' : 30, + 'padding_left' : 20} -class Home(Table) : + +class Home(object, Table) : """ Écran de démarrage de minwii """ @@ -38,72 +43,77 @@ class Home(Table) : style = {'valign' : 0, 'width' : pygame.display.get_surface().get_width(), 'height' : pygame.display.get_surface().get_height()} - print style params['style'] = style Table.__init__(self,**params) self.songPath = params.get('songPath', '.') self.nwiimotes = params.get('nwiimotes', 0) - self.songFile = None + self.songFile = params.get('songFile', '') self.spaceSize = (100,100) self.font = pygame.font.Font(None,70) self._fill() - #self._initLocalListeners() + self.selectedPlayMode = params.get('playMode', 'NORMAL') + self.selectedWiimoteIndex = params.get('wiimoteIndex', 0) + self._initLocalListeners() def _fill(self): - #self.tr() - #self.td(Spacer(*self.spaceSize)) - - # bouton pour browser de fichiers self.tr() - self.td(self.createLabel("Chanson :"), style = STYLE_LEFT_COL) + st = STYLE_LEFT_COL.copy() + st['valign'] = -1 + self.td(self.createLabel("Chanson :"), rowspan=2, style = st) self.browseButton = Button(self.createLabel("Choisir...")) self.td(self.browseButton,colspan=2, style = STYLE_RIGHT_COL) -# self.tr() -# self.songTitle = self.createLabel(u' ') -# self.td(self.songTitle, colspan=2, style = STYLE) -# -# # choix du niveau -# self.tr() -# self.td(self.createLabel("Niveau :")) -# self.modeSelect = Select('NORMAL') -# for k, caption in PLAYING_MODES : -# self.modeSelect.add(self.createLabel(caption), k) -# self.td(self.modeSelect,colspan=3) -# -# #self.tr() -# #self.td(Spacer(*self.spaceSize)) -# -# # choix des wiimotes -# self.tr() -# self.td(self.createLabel("Wiimote :", self.font)) -# playerTable = Table() -# -# self.selectedWiimote = Group(name='selectedWiimote', value=0) -# for i in range(self.nwiimotes): -# r = Radio(self.selectedWiimote, i) -# playerTable.td(r) -# playerTable.td(self.createLabel(" %d " % (i+1))) -# self.td(playerTable,colspan = 3) -# -# #self.tr() -# #self.td(Spacer(*self.spaceSize)) -# -# # boutons jouer / quitter -# self.tr() -# self.quitButton = Button(self.createLabel("Quitter")) -# self.td(self.quitButton) -# self.playButton = Button(self.createLabel("Jouer"), disabled=True) -# self.td(self.playButton,colspan=3) + self.tr() + caption = '' if not self.songFile else FileOpenDialog.getSongTitle(self.songFile) + self.songTitle = self.createLabel(caption) + st = STYLE_RIGHT_COL.copy() + del st['padding_top'] + self.td(self.songTitle, style = st) + + # choix du niveau + self.tr() + self.td(self.createLabel("Niveau :"), style=STYLE_LEFT_COL) + self.modeSelect = Select('NORMAL') + for k, caption in PLAYING_MODES : + self.modeSelect.add(self.createLabel(caption), k) + self.td(self.modeSelect,colspan=3, style=STYLE_RIGHT_COL) + + # choix des wiimotes + self.tr() + self.td(self.createLabel("Wiimote :", self.font), style=STYLE_LEFT_COL) + playerTable = Table() + + self.selectedWiimote = Group(name='selectedWiimote', value=0) + for i in range(self.nwiimotes): + r = Radio(self.selectedWiimote, i) + playerTable.td(r) + playerTable.td(self.createLabel(" %d " % (i+1))) + self.td(playerTable, style=STYLE_RIGHT_COL) - #self.tr() - #self.td(Spacer(500,500)) + # boutons jouer / quitter + self.tr() + self.quitButton = Button(self.createLabel("Quitter")) + self.td(self.quitButton, style={'padding_top' : 50}) + self.playButton = Button(self.createLabel("Jouer"), disabled=not self.songFile) + self.td(self.playButton, style={'padding_top' : 50}) + + @property + def selectedPlayMode(self) : + return self.modeSelect.value + + @selectedPlayMode.setter + def selectedPlayMode(self, value) : + self.modeSelect.value = value @property def selectedWiimoteIndex(self) : return self.selectedWiimote.value + + @selectedWiimoteIndex.setter + def selectedWiimoteIndex(self, value) : + self.selectedWiimote.value = value def _initLocalListeners(self) : self.browseButton.connect(CLICK, self.open_file_browser) @@ -133,8 +143,9 @@ class Home(Table) : def handle_file_browser_closed(self, dlg) : if dlg.value and os.path.isfile(dlg.value): self.remove(self.songTitle) - self.songTitle = self.createLabel(os.path.basename(dlg.value)) - self.td(self.songTitle, col=0, row=1, colspan=2, style={'align':1}) + title = FileOpenDialog.getSongTitle(dlg.value) + self.songTitle = self.createLabel(title) + self.td(self.songTitle, col=1, row=1, style=STYLE_RIGHT_COL) self.songFile = dlg.value self.playButton.disabled = False