b7b749e9627e4554aa6a249b2d0f3bf77827fea3
[minwii.git] / src / minwii / logapp.py
1 # -*- coding: utf-8 -*-
2 """
3 Interface graphique pour l'analyse des fichiers de log minwii.
4
5 $Id$
6 $URL$
7 """
8
9 from Tkinter import *
10 import tkFileDialog
11
12 class Application(Frame) :
13 def __init__(self, master=None) :
14 Frame.__init__(self, master)
15 self.grid()
16 self.createWidgets()
17 self.logDir = ''
18
19 def createWidgets(self) :
20 self.nav = Navbar(self)
21 self.chooseLogDir = Button(self, text="Parcourir…", command=self.openFileDialog)
22 self.chooseLogDir.grid()
23 self.quitButton = Button(self, text='Terminer', command=self.quit)
24 self.quitButton.grid()
25
26 def openFileDialog(self) :
27 self.logDir = tkFileDialog.askdirectory()
28
29
30 class Navbar(Frame) :
31 def __init__(self, master=None, from_=1, to=10, start=1, step=1) :
32 Frame.__init__(self, master)
33 self.from_ = from_
34 self.to = to
35 self.index = start
36 self.step = step
37 self.grid()
38 self.caption = StringVar()
39 self.caption.set('%d / %d' % (self.index, self.to))
40 self.createWidgets()
41
42 def createWidgets(self) :
43 self.backBtn = Button(self,
44 text='◀',
45 state = DISABLED if self.index==self.from_ else NORMAL,
46 command = self.dec
47 )
48 self.backBtn.grid(row=0, column=0)
49
50 self.lbl = Label(self, textvariable=self.caption)
51 self.lbl.grid(row=0, column=1)
52
53 self.nextBtn = Button(self,
54 text='▶',
55 state = DISABLED if self.index==self.to else NORMAL,
56 command = self.inc)
57 self.nextBtn.grid(row=0, column=2)
58
59 def dec(self) :
60 self.index = self.index - self.step
61 self.caption.set('%d / %d' % (self.index, self.to))
62 if self.index == self.from_ :
63 self.backBtn.configure(state=DISABLED)
64 if self.index < self.to :
65 self.nextBtn.configure(state=NORMAL)
66
67 def inc(self) :
68 self.index = self.index + self.step
69 self.caption.set('%d / %d' % (self.index, self.to))
70 if self.index == self.to :
71 self.nextBtn.configure(state=DISABLED)
72 if self.index > self.from_ :
73 self.backBtn.configure(state=NORMAL)
74
75
76 app = Application()
77 app.master.title("Analyseur des sessions MINWii")
78 app.mainloop()