-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpart.py
37 lines (31 loc) · 849 Bytes
/
part.py
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
from tkinter import *
root = Tk()
t = Text(root)
t.insert(END, '''\
blah blah blah Failed blah blah
blah blah blah Passed blah blah
blah blah blah Failed blah blah
blah blah blah Failed blah blah
''')
t.tag_config('failed', background='red')
t.tag_config('passed', background='blue')
def search(text_widget, keyword, tag):
pos = '1.0'
while True:
idx = text_widget.search(keyword, pos, END)
if not idx:
break
pos = '{}+{}c'.format(idx, len(keyword))
text_widget.tag_add(tag, idx, pos)
def Refresher():
# global text
# text.configure(text=time.asctime())
search(t, 'Passed', 'passed')
root.after(1000, Refresher) # every second...
t.pack()
search(t, 'Failed', 'failed')
search(t, 'Passed', 'passed')
Refresher()
#t.tag_delete('failed')
#t.tag_delete('passed')
root.mainloop()