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 minwii
.globals import PLAYING_MODES
21 from songfilebrowser
import FileOpenDialog
24 STYLE_LEFT_COL
= {'border_right' : 2,
27 STYLE_RIGHT_COL
= {'border_right' : 2,
34 Écran de démarrage de minwii
37 def __init__(self
,**params
):
38 style
= {'valign' : 0,
39 'width' : pygame
.display
.get_surface().get_width(),
40 'height' : pygame
.display
.get_surface().get_height()}
42 params
['style'] = style
43 Table
.__init
__(self
,**params
)
44 self
.songPath
= params
.get('songPath', '.')
45 self
.nwiimotes
= params
.get('nwiimotes', 0)
47 self
.spaceSize
= (100,100)
48 self
.font
= pygame
.font
.Font(None,70)
50 #self._initLocalListeners()
55 #self.td(Spacer(*self.spaceSize))
58 # bouton pour browser de fichiers
60 self
.td(self
.createLabel("Chanson :"), style
= STYLE_LEFT_COL
)
61 self
.browseButton
= Button(self
.createLabel("Choisir..."))
62 self
.td(self
.browseButton
,colspan
=2, style
= STYLE_RIGHT_COL
)
65 # self.songTitle = self.createLabel(u' ')
66 # self.td(self.songTitle, colspan=2, style = STYLE)
70 # self.td(self.createLabel("Niveau :"))
71 # self.modeSelect = Select('NORMAL')
72 # for k, caption in PLAYING_MODES :
73 # self.modeSelect.add(self.createLabel(caption), k)
74 # self.td(self.modeSelect,colspan=3)
77 # #self.td(Spacer(*self.spaceSize))
79 # # choix des wiimotes
81 # self.td(self.createLabel("Wiimote :", self.font))
82 # playerTable = Table()
84 # self.selectedWiimote = Group(name='selectedWiimote', value=0)
85 # for i in range(self.nwiimotes):
86 # r = Radio(self.selectedWiimote, i)
88 # playerTable.td(self.createLabel(" %d " % (i+1)))
89 # self.td(playerTable,colspan = 3)
92 # #self.td(Spacer(*self.spaceSize))
94 # # boutons jouer / quitter
96 # self.quitButton = Button(self.createLabel("Quitter"))
97 # self.td(self.quitButton)
98 # self.playButton = Button(self.createLabel("Jouer"), disabled=True)
99 # self.td(self.playButton,colspan=3)
102 #self.td(Spacer(500,500))
105 def selectedWiimoteIndex(self
) :
106 return self
.selectedWiimote
.value
108 def _initLocalListeners(self
) :
109 self
.browseButton
.connect(CLICK
, self
.open_file_browser
)
110 self
.quitButton
.connect(CLICK
, self
._exitApp
)
111 self
.playButton
.connect(CLICK
, self
._exitHome
)
113 def _exitApp(self
, data
=None) :
117 def _exitHome(self
, data
=None) :
121 def createLabel(self
,text
,font
= None):
124 w
,h
= self
.font
.size(text
)
125 label
= Label(text
,width
=w
,height
=h
,font
= font
)
128 def open_file_browser(self
):
129 dlg
= FileOpenDialog(self
.songPath
)
130 dlg
.connect(CHANGE
, self
.handle_file_browser_closed
, dlg
)
133 def handle_file_browser_closed(self
, dlg
) :
134 if dlg
.value
and os
.path
.isfile(dlg
.value
):
135 self
.remove(self
.songTitle
)
136 self
.songTitle
= self
.createLabel(os
.path
.basename(dlg
.value
))
137 self
.td(self
.songTitle
, col
=0, row
=1, colspan
=2, style
={'align':1})
138 self
.songFile
= dlg
.value
139 self
.playButton
.disabled
= False