1 # -*- coding: utf-8 -*-
3 Écran de démarrage minwii.
8 from pgu
.gui
import Table
9 from pgu
.gui
import Spacer
10 from pgu
.gui
import Label
11 from pgu
.gui
import Button
12 from pgu
.gui
import Switch
13 from pgu
.gui
import Radio
14 from pgu
.gui
import Group
15 from pgu
.gui
import Select
16 from pgu
.gui
import CLICK
17 from pgu
.gui
import QUIT
18 from pgu
.gui
import CHANGE
20 from globals import PLAYING_MODES
21 from songfilebrowser
import FileOpenDialog
26 Écran de démarrage de minwii
29 def __init__(self
,**params
):
30 Table
.__init
__(self
,**params
)
31 self
.songPath
= params
.get('songPath', '.')
32 self
.nwiimotes
= params
.get('nwiimotes', 0)
34 self
.spaceSize
= (100,100)
35 self
.font
= pygame
.font
.Font(None,70)
37 self
._initLocalListeners
()
42 self
.td(Spacer(*self
.spaceSize
))
45 # bouton pour browser de fichiers
47 self
.td(self
.createLabel("Chanson :"))
48 self
.browseButton
= Button(self
.createLabel("Choisir..."))
49 self
.td(self
.browseButton
,colspan
=2)
50 self
.songSwitch
= Switch(False)
51 self
.td(self
.songSwitch
)
54 self
.td(Spacer(*self
.spaceSize
))
58 self
.td(self
.createLabel("Niveau :"))
59 self
.modeSelect
= Select('NORMAL')
60 for k
, caption
in PLAYING_MODES
:
61 self
.modeSelect
.add(self
.createLabel(caption
), k
)
62 self
.td(self
.modeSelect
,colspan
=3)
65 self
.td(Spacer(*self
.spaceSize
))
69 self
.td(self
.createLabel("Wiimote :", self
.font
))
72 self
.selectedWiimote
= Group(name
='selectedWiimote', value
=0)
73 for i
in range(self
.nwiimotes
):
74 r
= Radio(self
.selectedWiimote
, i
)
76 playerTable
.td(self
.createLabel(" %d " % (i
+1)))
77 self
.td(playerTable
,colspan
= 3)
80 self
.td(Spacer(*self
.spaceSize
))
82 # boutons jouer / quitter
84 self
.quitButton
= Button(self
.createLabel("Quitter"))
85 self
.td(self
.quitButton
)
86 self
.playButton
= Button(self
.createLabel("Jouer"), disabled
=True)
87 self
.td(self
.playButton
,colspan
=3)
90 self
.td(Spacer(500,500))
93 def selectedWiimoteIndex(self
) :
94 return self
.selectedWiimote
.value
96 def _initLocalListeners(self
) :
97 self
.browseButton
.connect(CLICK
, self
.open_file_browser
)
98 self
.quitButton
.connect(CLICK
, self
._exitApp
)
99 self
.playButton
.connect(CLICK
, self
._exitHome
)
101 def _exitApp(self
, data
=None) :
105 def _exitHome(self
, data
=None) :
109 def createLabel(self
,text
,font
= None):
112 w
,h
= self
.font
.size(text
)
113 label
= Label(text
,width
=w
,height
=h
,font
= font
)
116 def open_file_browser(self
):
117 dlg
= FileOpenDialog(self
.songPath
)
118 dlg
.connect(CHANGE
, self
.handle_file_browser_closed
, dlg
)
121 def handle_file_browser_closed(self
, dlg
) :
122 if dlg
.value
and os
.path
.isfile(dlg
.value
):
123 self
.songFile
= dlg
.value
124 self
.playButton
.disabled
= False