1 # -*- coding: utf-8 -*-
3 Interface graphique pour l'analyse des fichiers de log minwii.
12 from os
.path
import join
as pjoin
13 from os
.path
import basename
15 class Application(Frame
) :
16 def __init__(self
, master
=None) :
17 Frame
.__init
__(self
, master
)
18 self
.configureStretching()
23 def configureStretching(self
) :
24 top
=self
.winfo_toplevel()
25 top
.rowconfigure(0, weight
=1)
26 top
.columnconfigure(0, weight
=1)
28 self
.grid(sticky
=N
+S
+E
+W
, padx
=10, pady
=10)
29 self
.rowconfigure(0, weight
=1)
30 self
.columnconfigure(0, weight
=1)
32 def createWidgets(self
) :
33 # zone d'affichage des données'
34 self
.dataFrame
= df
= Frame(self
)
37 self
.identFrame
= Identification(df
)
38 self
.identFrame
.grid(sticky
=NW
)
39 self
.nav
= Navbar(df
, incCallback
=self
.loadLogFile
, decCallback
=self
.loadLogFile
)
44 self
.btnFrame
= bf
= Frame(self
)
45 bf
.grid(row
=1, column
=0, sticky
=W
+S
+E
)
46 bf
.rowconfigure(0, weight
=1)
47 bf
.columnconfigure(0, weight
=1)
48 bf
.columnconfigure(1, weight
=1)
51 self
.chooseLogDir
= Button(bf
, text
="Parcourir…", command
=self
.openFileDialog
)
52 self
.chooseLogDir
.grid(row
=0, column
=0, sticky
=W
)
54 self
.quitButton
= Button(bf
, text
='Terminer', command
=self
.quit
)
55 self
.quitButton
.grid(row
=0, column
=1, sticky
=E
)
57 def openFileDialog(self
) :
58 self
.logDir
= tkFileDialog
.askdirectory()
60 self
.logFiles
= glob(pjoin(self
.logDir
, '*.log'))
62 self
.dataFrame
.grid(row
=0, column
=0, sticky
=NW
)
63 self
.nav
.setSize(len(self
.logFiles
))
64 self
.loadLogFile(self
.nav
)
66 def loadLogFile(self
, nav
) :
68 filepath
= self
.logFiles
[index
]
69 filename
= basename(filepath
)
70 self
.identFrame
.setFileName(filename
)
74 def __init__(self
, master
=None, size
=1, incCallback
=None, decCallback
=None) :
75 Frame
.__init
__(self
, master
)
76 self
.caption
= StringVar()
79 self
.incCallback
= incCallback
if incCallback
else lambda x
: None
80 self
.decCallback
= decCallback
if decCallback
else lambda x
: None
82 self
.caption
.set('%d / %d' % (self
.index
, self
.to
))
84 def createWidgets(self
) :
85 self
.backBtn
= Button(self
,
89 self
.backBtn
.grid(row
=0, column
=0)
91 self
.lbl
= Label(self
, textvariable
=self
.caption
)
92 self
.lbl
.grid(row
=0, column
=1)
94 self
.nextBtn
= Button(self
,
97 self
.nextBtn
.grid(row
=0, column
=2)
99 def refreshStates(self
) :
100 if self
.index
== self
.from_
:
101 self
.backBtn
.configure(state
=DISABLED
)
103 self
.backBtn
.configure(state
=NORMAL
)
105 if self
.index
< self
.to
:
106 self
.nextBtn
.configure(state
=NORMAL
)
108 self
.nextBtn
.configure(state
=DISABLED
)
110 self
.caption
.set('%d / %d' % (self
.index
, self
.to
))
114 self
.index
= self
.index
- 1
116 self
.decCallback(self
)
119 self
.index
= self
.index
+ 1
121 self
.incCallback(self
)
123 def setSize(self
, size
) :
130 class Identification(Frame
) :
131 def __init__(self
, master
=None) :
132 Frame
.__init
__(self
, master
)
133 self
.fileName
= StringVar()
136 def setFileName(self
, name
) :
137 self
.fileName
.set(name
)
139 def createWidgets(self
) :
140 fileLbl
= Label(self
, text
='Fichier :')
141 fileLbl
.grid(row
=0, column
=0, sticky
=E
)
143 fileNameLbl
= Label(self
, textvariable
=self
.fileName
)
144 fileNameLbl
.grid(row
=0, column
=1, sticky
=W
)
146 nameLbl
= Label(self
, text
='Patient :')
147 nameLbl
.grid(row
=1, column
=0, sticky
=E
)
149 self
.nameEntry
= Entry(self
, width
=40)
150 self
.nameEntry
.grid(row
=1, column
=1, sticky
=W
)
152 commentsLbl
= Label(self
, text
='Commentaires :')
153 commentsLbl
.grid(row
=2, column
=0, sticky
=E
)
155 self
.commentsText
= Text(self
, width
=40, height
=4, undo
=True, wrap
=WORD
)
156 self
.commentsText
.grid(row
=2, column
=1, sticky
=W
)
160 app
.master
.title("Analyseur des sessions MINWii")