on va plutôt faire un dossier pour les widgets.
[minwii.git] / src / app / widgets.py
1 # -*- coding: utf-8 -*-
2 """
3 widgets minwii.
4
5 $Id$
6 $URL$
7 """
8 from pgu.gui import Table, Spacer, Label, Button, Switch, Select
9 import pygame
10 from gui.constants import reversedReadabilityDict, modeDict
11
12 class Home(Table) :
13 """
14 Écran de démarrage de minwii
15 """
16
17 def __init__(self,**params):
18 Table.__init__(self,**params)
19 self.spaceSize = (100,100)
20 self.font = pygame.font.Font(None,70)
21 self._fill()
22
23
24 def _fill(self):
25 self.tr()
26 self.td(Spacer(*self.spaceSize))
27
28
29 # bouton pour browser de fichiers
30 self.tr()
31 self.td(self.createLabel("Chanson :"))
32 self.browseButton = Button(self.createLabel("Choisir..."))
33 self.td(self.browseButton,colspan=2)
34 self.songSwitch = Switch(False)
35 self.td(self.songSwitch)
36
37 self.tr()
38 self.td(Spacer(*self.spaceSize))
39
40 # choix du niveau
41 self.tr()
42 self.td(self.createLabel("Niveau :"))
43 self.modeSelect = Select('easy')
44 for key in modeDict.keys() :
45 self.modeSelect.add(self.createLabel(reversedReadabilityDict[key]),key)
46 self.td(self.modeSelect,colspan=3)
47
48 self.tr()
49 self.td(Spacer(*self.spaceSize))
50
51 # choix des wiimotes
52 self.tr()
53 self.td(self.createLabel("Joueurs :", self.font))
54 playerTable = Table()
55 self.activeWiimoteSwitches = []
56 for i in range(4):
57 s = Switch(False)
58 playerTable.td(s)
59 playerTable.td(self.createLabel(" %d " % (i+1)))
60 self.activeWiimoteSwitches.append(s)
61 self.td(playerTable,colspan = 3)
62
63 self.tr()
64 self.td(Spacer(*self.spaceSize))
65
66 # boutons jouer / quitter
67 self.tr()
68 self.quitButton = Button(self.createLabel("Quitter"))
69 self.td(self.quitButton)
70 self.goButton = Button(self.createLabel("Jouer"))
71 self.td(self.goButton,colspan=3)
72
73 self.tr()
74 self.td(Spacer(500,500))
75
76 def createLabel(self,text,font = None):
77 if font == None :
78 font = self.font
79 w,h = self.font.size(text)
80 label = Label(text,width=w,height=h,font = font)
81 return(label)
82
83
84