From: pin Date: Tue, 8 Jun 2010 15:13:37 +0000 (+0000) Subject: Un peu de refactoring. X-Git-Url: https://svn.cri.ensmp.fr/git/minwii.git/commitdiff_plain/832d3600014a2e21565964fb8e5e39192c6640d1 Un peu de refactoring. git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@223 fe552daf-6dbe-4428-90eb-1537e0879342 --- diff --git a/src/minwii/widgets/home.py b/src/minwii/widgets/home.py index e1f95c4..18e1c6f 100755 --- a/src/minwii/widgets/home.py +++ b/src/minwii/widgets/home.py @@ -21,12 +21,25 @@ 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} + + class Home(Table) : """ Écran de démarrage de minwii """ def __init__(self,**params): + 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) @@ -34,60 +47,59 @@ class Home(Table) : self.spaceSize = (100,100) self.font = pygame.font.Font(None,70) self._fill() - self._initLocalListeners() + #self._initLocalListeners() def _fill(self): - self.tr() - self.td(Spacer(*self.spaceSize)) + #self.tr() + #self.td(Spacer(*self.spaceSize)) # bouton pour browser de fichiers self.tr() - self.td(self.createLabel("Chanson :")) + self.td(self.createLabel("Chanson :"), style = STYLE_LEFT_COL) self.browseButton = Button(self.createLabel("Choisir...")) - self.td(self.browseButton,colspan=2) - self.songSwitch = Switch(False) - self.td(self.songSwitch) - - self.tr() - self.td(Spacer(*self.spaceSize)) - - # 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)) + self.td(self.browseButton,colspan=2, style = STYLE_RIGHT_COL) - # 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() +# 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() - self.td(Spacer(500,500)) + #self.tr() + #self.td(Spacer(500,500)) @property def selectedWiimoteIndex(self) : @@ -120,6 +132,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}) self.songFile = dlg.value self.playButton.disabled = False