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 Select
14 from pgu
.gui
import CLICK
15 from pgu
.gui
import QUIT
16 from pgu
.gui
import CHANGE
18 from gui
.constants
import reversedReadabilityDict
, modeDict
19 from songfilebrowser
import FileOpenDialog
24 Écran de démarrage de minwii
27 def __init__(self
,**params
):
28 Table
.__init
__(self
,**params
)
29 self
.songPath
= params
.get('songPath', '.')
31 self
.spaceSize
= (100,100)
32 self
.font
= pygame
.font
.Font(None,70)
34 self
._initLocalListeners
()
39 self
.td(Spacer(*self
.spaceSize
))
42 # bouton pour browser de fichiers
44 self
.td(self
.createLabel("Chanson :"))
45 self
.browseButton
= Button(self
.createLabel("Choisir..."))
46 self
.td(self
.browseButton
,colspan
=2)
47 self
.songSwitch
= Switch(False)
48 self
.td(self
.songSwitch
)
51 self
.td(Spacer(*self
.spaceSize
))
55 self
.td(self
.createLabel("Niveau :"))
56 self
.modeSelect
= Select('easy')
57 for key
in modeDict
.keys() :
58 self
.modeSelect
.add(self
.createLabel(reversedReadabilityDict
[key
]),key
)
59 self
.td(self
.modeSelect
,colspan
=3)
62 self
.td(Spacer(*self
.spaceSize
))
66 self
.td(self
.createLabel("Joueurs :", self
.font
))
68 self
.activeWiimoteSwitches
= []
72 playerTable
.td(self
.createLabel(" %d " % (i
+1)))
73 self
.activeWiimoteSwitches
.append(s
)
74 self
.td(playerTable
,colspan
= 3)
77 self
.td(Spacer(*self
.spaceSize
))
79 # boutons jouer / quitter
81 self
.quitButton
= Button(self
.createLabel("Quitter"))
82 self
.td(self
.quitButton
)
83 self
.playButton
= Button(self
.createLabel("Jouer"))
84 self
.td(self
.playButton
,colspan
=3)
87 self
.td(Spacer(500,500))
89 def _initLocalListeners(self
) :
90 self
.browseButton
.connect(CLICK
, self
.open_file_browser
)
91 self
.quitButton
.connect(CLICK
, self
._exitHome
)
93 def _exitHome(self
, data
=None) :
96 def createLabel(self
,text
,font
= None):
99 w
,h
= self
.font
.size(text
)
100 label
= Label(text
,width
=w
,height
=h
,font
= font
)
103 def open_file_browser(self
):
104 dlg
= FileOpenDialog(self
.songPath
)
105 dlg
.connect(CHANGE
, self
.handle_file_browser_closed
, dlg
)
108 def handle_file_browser_closed(self
, dlg
) :
109 if dlg
.value
and os
.path
.isfile(dlg
.value
):
110 self
.songFile
= dlg
.value