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
._exitApp
)
92 self
.playButton
.connect(CLICK
, self
._exitHome
)
94 def _exitApp(self
, data
=None) :
95 self
.returnValue
= False
98 def _exitHome(self
, data
=None) :
99 self
.returnValue
= True
102 def createLabel(self
,text
,font
= None):
105 w
,h
= self
.font
.size(text
)
106 label
= Label(text
,width
=w
,height
=h
,font
= font
)
109 def open_file_browser(self
):
110 dlg
= FileOpenDialog(self
.songPath
)
111 dlg
.connect(CHANGE
, self
.handle_file_browser_closed
, dlg
)
114 def handle_file_browser_closed(self
, dlg
) :
115 if dlg
.value
and os
.path
.isfile(dlg
.value
):
116 self
.songFile
= dlg
.value