pygame_wiitest.py en état de marche (à l'arrache tout de même).
[minwii.git] / src / gui / MINWiiDialog.py
1 # -*- coding: utf-8 -*-
2 '''
3 Created on 17 dec. 2009
4
5 @author: samsam
6 '''
7
8 import pgu.gui as pguGui
9 import os
10 import constants
11
12 class MINWiiDialog(pguGui.FileDialog):
13 '''
14 classdocs
15 '''
16
17 def __init__(self, font = None, width = 800, height = 600,path=None):
18 pguGui.FileDialog.__init__(self,title_txt = "Choisir une chanson", customFont = font,customWidth = width, customHeight = height,folderText = "", fileText = "",path =path,showCurDir = False)
19
20 def _list_dir_(self):
21 self.input_dir.value = self.curdir
22 self.input_dir.pos = len(self.curdir)
23 self.input_dir.vpos = 0
24 dirs = []
25 files = []
26 try:
27 for i in os.listdir(self.curdir):
28 if os.path.isdir(os.path.join(self.curdir, i)): dirs.append(i)
29 else: files.append(i)
30 except:
31 self.input_file.value = "Opps! no access"
32 #if '..' not in dirs: dirs.append('..')
33 dirs.sort()
34 dirs = ['..'] + dirs
35
36 files.sort()
37 for i in dirs:
38 #item = ListItem(image=self.dir_img, text=i, value=i)
39 if self.customFont == None :
40 self.list.add(i,image=self.dir_img,value=i)
41 else :
42 if i == ".." or i[0] != ".":
43 label = pguGui.basic.Label(i,font = self.customFont)
44 self.list.add(label,image=self.dir_img,value=i)
45 for i in files:
46 #item = ListItem(image=None, text=i, value=i)
47 if self.customFont == None :
48 self.list.add(i,value=i)
49 else:
50 if i.endswith(".smwi"):
51 key = i[:-5]
52 if key in constants.reversedReadabilityDict :
53 label = pguGui.basic.Label(constants.reversedReadabilityDict[key],font = self.customFont)
54 else :
55 label = pguGui.basic.Label(key,font = self.customFont)
56 self.list.add(label,value=i)
57 elif i.endswith(".xml") :
58 # TODO : afficher le Titre de la chanson au lieu du nom
59 # de fichier
60 label = pguGui.basic.Label(i, font=self.customFont)
61 self.list.add(label,value=i)
62 #self.list.resize()
63 self.list.set_vertical_scroll(0)
64 #self.list.repaintall()
65