开两个窗口
# encoding: utf-8
import time
from Tkinter import *
class log():
def write_log_windows(self,file1, file2):
with open(file1) as f1:
self.windows1()
self.windows2()
for line in f1:
f2 = open(file2, 'a+')
f2.write(line)
self.textpad1.insert(END, line)
self.textpad2.insert(END, line)
self.textpad1.see(END)
self.textpad2.see(END)
self.root1.update()
self.root2.update()
def windows1(self):
self.root1 = Tk()
self.root1.title("serial log")
s1 = Scrollbar(self.root1)
s1.pack(side=RIGHT, fill=Y)
s2 = Scrollbar(self.root1, orient=HORIZONTAL)
s2.pack(side=BOTTOM, fill=X)
self.textpad1 = Text(self.root1, yscrollcommand=s1.set, xscrollcommand=s2.set, wrap='none