From 2f76050b40fd8c5ac811b3f4b94618180ff547ba Mon Sep 17 00:00:00 2001 From: pin Date: Thu, 10 Jun 2010 15:28:11 +0000 Subject: [PATCH 1/1] =?utf8?q?conservation=20des=20param=C3=A8tres=20lors?= =?utf8?q?=20du=20retour=20=C3=A0=20l'=C3=A9cran=20d'accueil.?= 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@227 fe552daf-6dbe-4428-90eb-1537e0879342 --- src/minwii/app.py | 16 +++++++++++----- src/minwii/widgets/home.py | 23 +++++++++++++++++++---- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/minwii/app.py b/src/minwii/app.py index ad2e382..1160d5b 100755 --- a/src/minwii/app.py +++ b/src/minwii/app.py @@ -56,13 +56,16 @@ class MinWii(object): pygame.display.set_mode(self.screenResolution, displayFlags) pygame.display.set_caption('MINWii') WT = self.WT + + songFile, playMode, wiimoteIndex = '', 'NORMAL', 0 while True : - exit, songFile, playMode, selectedWiimoteIndex = self.selectSongAndOptions() + exit, songFile, playMode, wiimoteIndex = \ + self.selectSongAndOptions(songFile, playMode, wiimoteIndex) if exit : break - WT.selectWiimote(selectedWiimoteIndex) + WT.selectWiimote(wiimoteIndex) WT.resume() instrumentDescription = self.selectInstrument() @@ -75,7 +78,7 @@ class MinWii(object): WT.pause() - def selectSongAndOptions(self) : + def selectSongAndOptions(self, songFile, playMode, wiimoteIndex) : """ lance l'écran de paramétrage et retourne un tuple comportant : - drapeau de sortie de l'application (booléen) - chemin du fichier de la chanson @@ -83,6 +86,9 @@ class MinWii(object): - wiimote sélectionnée (entier) """ home = Home(songPath=SONG_FILE_PATH, + songFile=songFile, + playMode=playMode, + wiimoteIndex=wiimoteIndex, nwiimotes=self.nwiimotes) app = self.app home.connect(QUIT, app.quit) @@ -110,8 +116,8 @@ class MinWii(object): return (home.exitApp, home.songFile, - home.modeSelect.value, - home.selectedWiimote.value) + home.selectedPlayMode, + home.selectedWiimoteIndex) def selectInstrument(self) : """ lance l'écran de sélection de l'instrument et retourne diff --git a/src/minwii/widgets/home.py b/src/minwii/widgets/home.py index c5d1ff5..44c101f 100755 --- a/src/minwii/widgets/home.py +++ b/src/minwii/widgets/home.py @@ -34,7 +34,7 @@ STYLE_RIGHT_COL = {#'border_right' : 2, 'padding_left' : 20} -class Home(Table) : +class Home(object, Table) : """ Écran de démarrage de minwii """ @@ -47,10 +47,12 @@ class Home(Table) : 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.selectedPlayMode = params.get('playMode', 'NORMAL') + self.selectedWiimoteIndex = params.get('wiimoteIndex', 0) self._initLocalListeners() @@ -64,7 +66,8 @@ class Home(Table) : self.td(self.browseButton,colspan=2, style = STYLE_RIGHT_COL) self.tr() - self.songTitle = self.createLabel(u' ') + caption = os.path.basename(self.songFile) + self.songTitle = self.createLabel(caption) st = STYLE_RIGHT_COL.copy() del st['padding_top'] self.td(self.songTitle, style = st) @@ -93,12 +96,24 @@ class Home(Table) : self.tr() self.quitButton = Button(self.createLabel("Quitter")) self.td(self.quitButton, style={'padding_top' : 50}) - self.playButton = Button(self.createLabel("Jouer"), disabled=True) + 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) -- 2.20.1