implémentation bouton quitter.
[minwii.git] / src / app / widgets / home.py
1 # -*- coding: utf-8 -*-
2 """
3 widgets minwii.
4
5 $Id$
6 $URL$
7 """
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 import pygame
17 from gui.constants import reversedReadabilityDict, modeDict
18
19 class Home(Table) :
20 """
21 Écran de démarrage de minwii
22 """
23
24 def __init__(self,**params):
25 Table.__init__(self,**params)
26 self.spaceSize = (100,100)
27 self.font = pygame.font.Font(None,70)
28 self._fill()
29 self._initLocalListeners()
30
31
32 def _fill(self):
33 self.tr()
34 self.td(Spacer(*self.spaceSize))
35
36
37 # bouton pour browser de fichiers
38 self.tr()
39 self.td(self.createLabel("Chanson :"))
40 self.browseButton = Button(self.createLabel("Choisir..."))
41 self.td(self.browseButton,colspan=2)
42 self.songSwitch = Switch(False)
43 self.td(self.songSwitch)
44
45 self.tr()
46 self.td(Spacer(*self.spaceSize))
47
48 # choix du niveau
49 self.tr()
50 self.td(self.createLabel("Niveau :"))
51 self.modeSelect = Select('easy')
52 for key in modeDict.keys() :
53 self.modeSelect.add(self.createLabel(reversedReadabilityDict[key]),key)
54 self.td(self.modeSelect,colspan=3)
55
56 self.tr()
57 self.td(Spacer(*self.spaceSize))
58
59 # choix des wiimotes
60 self.tr()
61 self.td(self.createLabel("Joueurs :", self.font))
62 playerTable = Table()
63 self.activeWiimoteSwitches = []
64 for i in range(4):
65 s = Switch(False)
66 playerTable.td(s)
67 playerTable.td(self.createLabel(" %d " % (i+1)))
68 self.activeWiimoteSwitches.append(s)
69 self.td(playerTable,colspan = 3)
70
71 self.tr()
72 self.td(Spacer(*self.spaceSize))
73
74 # boutons jouer / quitter
75 self.tr()
76 self.quitButton = Button(self.createLabel("Quitter"))
77 self.td(self.quitButton)
78 self.playButton = Button(self.createLabel("Jouer"))
79 self.td(self.playButton,colspan=3)
80
81 self.tr()
82 self.td(Spacer(500,500))
83
84 def _initLocalListeners(self) :
85 self.quitButton.connect(CLICK, self.exit)
86
87 def exit(self, data=None) :
88 if data is None :
89 self.send(QUIT)
90
91 def createLabel(self,text,font = None):
92 if font == None :
93 font = self.font
94 w,h = self.font.size(text)
95 label = Label(text,width=w,height=h,font = font)
96 return(label)
97
98
99