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
| class Historique:
def afficher(self,event=""):
# Création de la fenetre
self.fen=Toplevel()
self.fen.title(_("Historique"))
# Création du menu
self.histMenu=Frame(self.fen,borderwidth=2,relief='groove')
self.searchBox=Entry(self.histMenu)
self.searchBox.bind("<Key>",self.cherche)
self.searchBox.pack(side='left')
self.histMenu.grid(columnspan=2,sticky='we')
# --- Création du Text "Hist" qui contiendra l'historique et de ses scrollbars ---
self.Hist=Text(self.fen,wrap='none',width=50,height=10)
self.sb1=Scrollbar(self.fen,orient='vertical')
self.sb2=Scrollbar(self.fen,orient='horizontal')
self.Hist.insert("0.0",varHist)
self.Hist.config(state='disabled',xscrollcommand=self.sb2.set,yscrollcommand=self.sb1.set)
self.sb1.config(command=self.Hist.yview)
self.sb2.config(command=self.Hist.xview)
self.Hist.grid(row=1,sticky='nsew')
self.sb1.grid(row=1,column=1,sticky='sn')
self.sb2.grid(row=2,sticky='we')
self.Hist.tag_configure('mot_cle',background='grey')
self.Hist.insert("0.0",varHist) # Chargement de l'historique dans le Text
self.Hist.bind('<F6>',self.selectAll) # La touche F6 selectionne le contenu du Widget Text pour qu'il puisse être copié
def cherche(self,event):
self.expr=self.searchBox.get()
self.nmbChar=IntVar()
self.lastPos="1.0"
self.Hist.tag_remove('mot_cle','1.0','end')
while 1 :
self.lastPos=self.Hist.search(self.expr,index=self.lastPos,stopindex='end',regexp=1,count=self.nmbChar)
if self.lastPos=="":break
self.Hist.tag_add('mot_cle',self.lastPos,"%s + %d chars" % (self.lastPos,self.nmbChar.get()))
self.lastPos = "%s + 1 chars" % self.lastPos |
Partager