1 # -*- coding: utf-8 -*-
3 Interface graphique pour l'analyse des fichiers de log minwii.
12 from os
.path
import join
as pjoin
14 class Application(Frame
) :
15 def __init__(self
, master
=None) :
16 Frame
.__init
__(self
, master
)
17 self
.configureStretching()
22 def configureStretching(self
) :
23 top
=self
.winfo_toplevel()
24 top
.rowconfigure(0, weight
=1)
25 top
.columnconfigure(0, weight
=1)
27 self
.grid(sticky
=N
+S
+E
+W
, padx
=10, pady
=10)
28 self
.rowconfigure(0, weight
=1)
29 self
.columnconfigure(0, weight
=1)
31 def createWidgets(self
) :
32 # zone d'affichage des données'
33 self
.dataFrame
= df
= Frame(self
)
36 self
.identFrame
= Identification(df
)
37 self
.identFrame
.grid(sticky
=NW
)
43 self
.btnFrame
= bf
= Frame(self
)
44 bf
.grid(row
=1, column
=0, sticky
=W
+S
+E
)
45 bf
.rowconfigure(0, weight
=1)
46 bf
.columnconfigure(0, weight
=1)
47 bf
.columnconfigure(1, weight
=1)
50 self
.chooseLogDir
= Button(bf
, text
="Parcourir…", command
=self
.openFileDialog
)
51 self
.chooseLogDir
.grid(row
=0, column
=0, sticky
=W
)
53 self
.quitButton
= Button(bf
, text
='Terminer', command
=self
.quit
)
54 self
.quitButton
.grid(row
=0, column
=1, sticky
=E
)
56 def openFileDialog(self
) :
57 self
.logDir
= tkFileDialog
.askdirectory()
59 self
.logFiles
= glob(pjoin(self
.logDir
, '*.log'))
61 self
.dataFrame
.grid(row
=0, column
=0, sticky
=NW
)
62 self
.nav
.setFileList(self
.logFiles
)
66 def __init__(self
, master
=None, from_
=1, to
=10, start
=1, step
=1) :
67 Frame
.__init
__(self
, master
)
73 self
.caption
= StringVar()
74 self
.caption
.set('%d / %d' % (self
.index
, self
.to
))
77 def createWidgets(self
) :
78 self
.backBtn
= Button(self
,
80 state
= DISABLED
if self
.index
==self
.from_
else NORMAL
,
83 self
.backBtn
.grid(row
=0, column
=0)
85 self
.lbl
= Label(self
, textvariable
=self
.caption
)
86 self
.lbl
.grid(row
=0, column
=1)
88 self
.nextBtn
= Button(self
,
90 state
= DISABLED
if self
.index
==self
.to
else NORMAL
,
92 self
.nextBtn
.grid(row
=0, column
=2)
94 def refreshStates(self
) :
95 if self
.index
== self
.from_
:
96 self
.backBtn
.configure(state
=DISABLED
)
98 self
.backBtn
.configure(state
=NORMAL
)
100 if self
.index
< self
.to
:
101 self
.nextBtn
.configure(state
=NORMAL
)
103 self
.nextBtn
.configure(state
=DISABLED
)
105 self
.caption
.set('%d / %d' % (self
.index
, self
.to
))
109 self
.index
= self
.index
- self
.step
113 self
.index
= self
.index
+ self
.step
116 def setFileList(self
, fileList
) :
117 self
.fileList
= fileList
119 self
.to
= len(self
.fileList
)
124 return self
.fileList
[self
.index
- 1]
127 class Identification(Frame
) :
128 def __init__(self
, master
=None) :
129 Frame
.__init
__(self
, master
)
130 self
.fileName
= StringVar()
133 def createWidgets(self
) :
134 fileLbl
= Label(self
, text
='Fichier :')
135 fileLbl
.grid(row
=0, column
=0)
137 fileNameLbl
= Label(self
, textvariable
=self
.fileName
)
139 nameLbl
= Label(self
, text
='Patient :')
140 nameLbl
.grid(row
=1, column
=0)
142 self
.nameEntry
= Entry(self
, width
=40)
143 self
.nameEntry
.grid(row
=1, column
=1)
145 commentsLbl
= Label(self
, text
='Commentaires :')
146 commentsLbl
.grid(row
=2, column
=0)
148 self
.commentsText
= Text(self
, width
=40, height
=4, undo
=True, wrap
=WORD
)
149 self
.commentsText
.grid(row
=2, column
=1)
153 app
.master
.title("Analyseur des sessions MINWii")