1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
| #-*- coding: iso-8859-15 -*-
# MAIN PROGRAM
try:
import wx
#import parseurLogsOvh as plog
except ImportError:
raise ImportError,"The wxPython module is required to run this program"
import time
# Constantes d'ID des cases à cocher du menu
CHK_ROUGE = 101
CHK_BLEU = 102
CHK_VERT = 103
SIZE_LARGEUR = 900
SIZE_HAUTEUR = 400
LAST_UPDATE = time.localtime()
TIMER_REFRESH = 50000
class Onglets(wx.Notebook):
# Classe dérivée du wx.Notebook
def __init__(self, parent):
wx.Notebook.__init__(self, parent, -1,size = (500, 500))
self.Centre()
def AjoutePage(self, nom):
self.win = wx.Panel(self)
self.vbox = wx.BoxSizer(wx.VERTICAL)
self.SetBackgroundColour(wx.BLUE)
w = self.AddPage(self.win, nom)
self.vbox.Add(self.win, 1,wx.SHAPED, 20)
self.win.SetSizer(self.vbox)
self.textbox = wx.TextCtrl(self.win,style = wx.TE_READONLY|wx.TE_MULTILINE|wx.HSCROLL)
def OnMiddleDown(self, event):
print'Refresh logs'
def SupprimePage(self, index):
# Méthode de suppression d'un onglet
self.DeletePage(index)
class Fenetre(wx.Frame):
# Frame destinée à tester notre notebook
def __init__(self):
#wx.Frame.__init__(self, None, -1, title = "Logs Monitoring", size = (SIZE_LARGEUR, SIZE_HAUTEUR))
wx.Frame.__init__(self, None, wx.ID_ANY, title = "Logs Monitoring",size = (SIZE_LARGEUR, SIZE_HAUTEUR))
# Recuperation de la date systeme
#plog.getDateSystem()
# Timer
self.timer = wx.Timer(self)
self.timer.Start(5000) # Tick toute les 5secondes
# Event Timer
self.Bind(wx.EVT_TIMER, self.RefreshLogs, self.timer)
# Création de la barre de menu avec la conf
self.AfficheMenu(None)
# Instanciation de notre classe Notebook
self.notebook = Onglets(self)
# Ajout de trois onglets dans le notebook
self.notebook.AjoutePage("PremierSite.fr")
self.notebook.AjoutePage("DeuxièmeSite.fr")
# On amorce le gestionnaire d'évènements du notebook
# 2- Pour celui qui intervient au moment du changement d'onglet
self.notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnChanging)
self.notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnChanging)
def AfficheMenu(self,event):
menubar = wx.MenuBar()
fileMenu = wx.Menu()
aboutMenu = wx.Menu()
# Sous Menus
aboutItem = wx.MenuItem(aboutMenu, wx.ID_ANY, '&About')
aboutMenu.AppendItem(aboutItem)
quitterItem = wx.MenuItem(fileMenu, wx.ID_EXIT, '&Quitter')
fileMenu.AppendItem(quitterItem)
self.Bind(wx.EVT_MENU, self.ShowMessageAbout,aboutItem)
self.Bind(wx.EVT_MENU, self.OnQuit, quitterItem)
# Main Menus
menubar.Append(fileMenu, '&Fichier')
menubar.Append(aboutMenu, '&?')
self.SetMenuBar(menubar)
# Actualisation de l'affichage des Logs
def RefreshLogs(self, event):
'''
dlg = wx.MessageDialog(None, "Mise à jour des logs",'Mise à jour des logs',wx.OK| wx.ICON_QUESTION)
retCode = dlg.ShowModal()
if (retCode == wx.ID_OK):
dlg.Destroy()
'''
print 'timer'
def ShowMessageAbout(self,e):
dial = wx.MessageBox('Information logiciel \n\n ', 'About', wx.OK | wx.ICON_INFORMATION)
dial.ShowModal()
def OnQuit(self, e):
self.timer.Stop()
self.Close()
def OnChanging(self, evt):
print 'On Changing'
class App(wx.App):
def OnInit(self):
f = Fenetre()
f.Show(True)
self.SetTopWindow(f)
return True
if __name__ == "__main__":
monApp = App()
monApp.MainLoop() |