that seems perfect, can you apply that to this:

import tkinter as tk
from tkinter import ttk
from tkinter import filedialog
import datetime
import os
import time

paths = [r"C:\Users\george\Desktop\sneakermonitors\Sneaker-Monitors-master\Sneaker-Monitors-master-alumni\shopify-monitor.log",
 r"C:\Users\george\Desktop\sneakermonitors\Sneaker-Monitors-master\Sneaker-Monitors-master-atmos\shopify-monitor.log",
 r"C:\Users\george\Desktop\sneakermonitors\Sneaker-Monitors-master\Sneaker-Monitors-master-creme123\shopify-monitor.log",
 r"C:\Users\george\Desktop\sneakermonitors\Sneaker-Monitors-master\Sneaker-Monitors-master-footlocker-benEdit\shopify-monitor.log",
 r"C:\Users\george\Desktop\sneakermonitors\Sneaker-Monitors-master\Sneaker-Monitors-master-kith\shopify-monitor.log",
 r"C:\Users\george\Desktop\sneakermonitors\Sneaker-Monitors-master\Sneaker-Monitors-master-kith-benEdit\shopify-monitor.log",
 r"C:\Users\george\Desktop\sneakermonitors\Sneaker-Monitors-master\Sneaker-Monitors-master-millennium\shopify-monitor.log",
 r"C:\Users\george\Desktop\sneakermonitors\Sneaker-Monitors-master\Sneaker-Monitors-master-premier\shopify-monitor.log",
 r"C:\Users\george\Desktop\sneakermonitors\Sneaker-Monitors-master\Sneaker-Monitors-master-shoe\_palace\shopify-monitor.log",
 r"C:\Users\george\Desktop\sneakermonitors\Sneaker-Monitors-master\Sneaker-Monitors-master-sneaker\shopify-monitor.log",
 r"C:\Users\george\Desktop\sneakermonitors\Sneaker-Monitors-master\Sneaker-Monitors-master-sneaker\_politics\shopify-monitor.log",
 r"C:\Users\george\Desktop\sneakermonitors\Sneaker-Monitors-master\Sneaker-Monitors-master-supreme\shopify-monitor.log",
 r"C:\Users\george\Desktop\sneakermonitors\Sneaker-Monitors-master\Sneaker-Monitors-master-undefeated\shopify-monitor.log"]

def tail(f, window=1):
 """
 Returns the last `window` lines of file `f` as a list of bytes.
 """
 if window == 0:
 return b''
 BUFSIZE = 1024
 f.seek(0, 2)
 end = f.tell()
 nlines = window + 1
 data = []
 while nlines > 0 and end > 0:
 i = max(0, end - BUFSIZE)
 nread = min(end, BUFSIZE)

 f.seek(i)
 chunk = f.read(nread)
 data.append(chunk)
 nlines -= chunk.count(b'\n')
 end -= nread
 return b'\n'.join(b''.join(reversed(data)).splitlines()[-window:])

def get\_recent\_log\_lines():
 current\_time = datetime.datetime.now()
 live\_monitors\_data = []
 dead\_monitors\_data = []

 for x in range(len(paths)):
 with open(paths[x], 'rb') as f:
 last\_lines = tail(f, 1).decode('utf-8')
 line\_list = last\_lines.splitlines()
 for y in range(len(line\_list)):
 line\_time = datetime.datetime(int(line\_list[y][:4]), int(line\_list[y][5:7]), int(line\_list[y][8:10]), int(line\_list[y][11:13]), int(line\_list[y][14:16]), int(line\_list[y][17:19]), int(line\_list[y][20:23]))
 line\_age = (current\_time - line\_time)
 name\_split = paths[x][88:].split("\\", 1)
 values = [name\_split[0], line\_age]
 if line\_age.total\_seconds() < 600:
 live\_monitors\_data.append(values)
 else:
 dead\_monitors\_data.append(values)
 return live\_monitors\_data, dead\_monitors\_data

sums\_seconds = []
counts = []

def refresh\_display():
 live\_mons, dead\_mons = get\_recent\_log\_lines()

 listbox2.delete(0, tk.END)
 listbox2.insert(tk.END, "Live Monitors: ( " + str(len(live\_mons)) + " )")
 live\_mons\_avg = []
 for mon in range(len(live\_mons)):
 # Initialize the sum and count for each monitor
 if mon >= len(sums\_seconds):
 sums\_seconds.append(0)
 counts.append(0)
 # Get the total seconds
 seconds = live\_mons[mon][1].total\_seconds()
 # Add to the sum and increase the count
 sums\_seconds[mon] += seconds
 counts[mon] += 1
 # Calculate the average
 average = sums\_seconds[mon] / counts[mon]
 # Append the monitor name, seconds and average to the list
 live\_mons\_avg.append((live\_mons[mon][0], round(seconds, 2), round(average, 2)))
 # Sort the list by the average
 sorted\_live\_mons = sorted(live\_mons\_avg, key=lambda x: x[2])
 # Print the sorted list
 for mon in range(len(sorted\_live\_mons)):
 listbox2.insert(tk.END,sorted\_live\_mons[mon][0] + ": " + str(sorted\_live\_mons[mon][1]) + " Average: " + str(sorted\_live\_mons[mon][2]))
 # Print the dead monitors
 listbox2.insert(tk.END, "")
 listbox2.insert(tk.END, "Dead Monitors: ( " + str(len(dead\_mons)) + " )")
 for mon in range(len(dead\_mons)):
 listbox2.insert(tk.END, dead\_mons[mon][0] + ": " + str(round(dead\_mons[mon][1].total\_seconds(), 2)) )
 root.after(1000, refresh\_display)
def button1\_clicked():
 live\_mons, dead\_mons = get\_recent\_log\_lines()

 listbox2.delete(0, tk.END)
 listbox2.insert(tk.END, "Live Monitors: ( " + str(len(live\_mons)) + " )")
 live\_mons\_avg = []
 for mon in range(len(live\_mons)):
 seconds = live\_mons[mon][1].total\_seconds()
 listbox2.insert(tk.END, live\_mons[mon][0] + ": " + str(round(seconds, 2)) )
 listbox2.insert(tk.END, "Dead Monitors: ( " + str(len(dead\_mons)) + " )")
 for mon in range(len(dead\_mons)):
 listbox2.insert(tk.END, dead\_mons[mon][0] + ": " + str(round(dead\_mons[mon][1].total\_seconds(), 2)) )
 pass

def button2\_clicked():
 # code for button 2
 pass

def add\_path():
 filepath = filedialog.askopenfilename()
 if filepath:
 paths.append(filepath)
 update\_listbox()

def remove\_path():
 selection = listbox1.curselection()
 if selection:
 index = int(selection[0])
 del paths[index]
 update\_listbox()

def update\_listbox():
 listbox1.delete(0, tk.END)
 for path in paths:
 listbox1.insert(tk.END, path)

root = tk.Tk()
root.geometry("1024x500")
root.title("MonMonGUI")

# Create a frame for the buttons
button\_frame = tk.Frame(root)
button\_frame.pack(side=tk.LEFT, fill=tk.Y)

# Create the buttons and add them to the button frame
button1 = tk.Button(button\_frame, text="Refresh MonMon", command=button1\_clicked)
button1.pack(fill=tk.X)
button2 = tk.Button(button\_frame, text="Button 2", command=button2\_clicked)
button2.pack(fill=tk.X)
button3 = tk.Button(button\_frame, text="Add File", command=add\_path)
button3.pack(fill=tk.X)

# Create a Tab Control
notebook = ttk.Notebook(root)
notebook.pack(fill=tk.BOTH, expand=True)

# Create Tab 1
tab1 = ttk.Frame(notebook)
listbox1 = tk.Listbox(tab1)
listbox1.pack(fill=tk.BOTH, expand=True)
notebook.add(tab1, text="Product Monitors")

# Create a remove button
remove\_button = tk.Button(tab1, text="Remove", command=remove\_path)
remove\_button.pack(side=tk.BOTTOM, anchor=tk.SE)

update\_listbox()

# Create Tab 2
tab2 = ttk.Frame(notebook)
notebook.add(tab2, text="MonMon")
listbox2 = tk.Listbox(tab2)
listbox2.pack(fill=tk.BOTH, expand=True)

root.after(1000, refresh\_display)
root.mainloop()
이 완벽해 보이는데, 여기에 적용해 볼 수 있을까요?tkinter를 tk로 가져 오기tkinter에서 ttk 가져 오기에서 파일 로그 가져 오기날짜 시간 가져 오기import os시간 가져오기경로 = [r"C:\사용자\조지\데스크톱\스니커모니터\스니커모니터-마스터\스니커모니터-마스터-동문\shopify-monitor.log", r"C:\사용자\george\데스크톱\스니커모니터\스니커모니터-마스터\스니커모니터-마스터-atmos\shopify-monitor.log","C:\사용자\george\데스크톱\스니커모니터-마스터\스니커모니터-마스터-졸업생\shopify-monitor.log", r"C:\사용자\george\데스크톱\스니커즈모니터\스니커즈모니터-마스터\스니커즈모니터-마스터-creme123\shopify-monitor.log", r"C:\사용자\george\데스크톱\스니커즈모니터\스니커즈모니터-마스터\스니커즈모니터-마스터-footlocker-benEdit\shopify-monitor.log", r"C:\사용자\george\데스크톱\스니커즈모니터\스니커즈모니터-마스터\스니커즈모니터-마스터-kith\shopify-monitor.log","C:\사용자\george\데스크톱\스니커즈모니터-마스터\스니커즈모니터-마스터-kith\shopify-monitor.log", r"C:\Users\george\Desktop\sneakermonitors\Sneaker-Monitors-master\Sneaker-Monitors-master-kith-benEdit\shopify-monitor.log","C:\Users\george\Desktop\sneakermonitors\Sneaker-Monitors-master-kith\shopify-monitor.log", r"C:\사용자\george\데스크톱\스니커즈모니터\스니커즈모니터-마스터\스니커즈모니터-마스터-밀레니엄\shopify-monitor.log", r"C:\사용자\george\데스크톱\스니커즈모니터\스니커즈모니터-마스터\스니커즈모니터-마스터-프리미어\shopify-monitor.log","C:\사용자\지상파\데스크톱\스니커즈모니터-마스터\스니커즈모니터-마스터-밀레니엄\쇼핑몰모니터.log r"C:\사용자\george\데스크톱\스니커즈모니터\스니커즈모니터-마스터\스니커즈모니터-마스터-슈즈\_궁전\shopify-monitor.log" r"C:\사용자\george\데스크톱\스니커즈모니터\스니커즈모니터-마스터\스니커즈모니터-마스터-스니커즈\shopify-monitor.log","C:\사용자\조지\데스크톱\스니커즈모니터-마스터\스니커즈모니터-마스터-신발\궁전\shopify-monitor.log r"C:\사용자\george\데스크탑\스니커모니터\스니커모니터-마스터\스니커모니터-마스터-스니커\_politics\shopify-monitor.log" r"C:\사용자\george\데스크톱\스니커모니터\스니커모니터-마스터\스니커모니터-마스터-최고\shopify-monitor.log","C:\사용자\george\데스크톱\스니커모니터-마스터\스니커모니터-마스터-supreme\shopify-monitor.log", r"C:\사용자\조지\데스크톱\스니커모니터\스니커모니터-마스터\스니커모니터-마스터-무패\shopify-monitor.log"]def tail(f, window=1): """ 파일 `f`의 마지막 `window` 줄을 바이트 목록으로 반환합니다. """ if window == 0: RETURN B'' BUFSIZE = 1024 f.seek(0, 2) end = f.tell() nlines = 창 + 1 data = [] nlines > 0이고 end > 0인 동안: i = max(0, end - BUFSIZE) nread = min(end, BUFSIZE) f.seek(i) chunk = f.read(nread) 데이터.추가(청크) nlines -= chunk.count(b'\n') end -= nread return b'\n'.join(b''.join(reversed(data)).splitlines()[-window:])def get\_recent\_log\_lines(): current\_time = datetime.datetime.now() live\_monitors\_data = [] dead\_monitors\_data = [] for x in range(len(paths)): with open(paths[x], 'rb') as f: last\_lines = tail(f, 1).decode('utf-8') line\_list = last\_lines.splitlines() for y in range(len(line\_list)): line\_time = datetime.datetime(int(line\_list[y][:4]), int(line\_list[y][5:7]), int(line\_list[y][8:10]), int(line\_list[y][11:13]), int(line\_list[y][14:16]), int(line\_list[y][17:19]), int(line\_list[y][20:23])) line\_age = (현재\_시간 - line\_시간) name\_split = paths[x][88:].split("\\", 1) values = [name\_split[0], line\_age] line\_age.total\_seconds() < 600: live\_monitors\_data.append(values) else: dead\_monitors\_data.append(values) 반환 라이브\_모니터\_data, 데드\_모니터\_datasums\_seconds = []counts = []def refresh\_display(): live\_mons, dead\_mons = get\_recent\_log\_lines() listbox2.delete(0, tk.END) listbox2.insert(tk.END,"실시간 모니터: ( " + str(len(live\_mons))) + " )") live\_mons\_avg = [] for mon in range(len(live\_mons)): # 각 모니터의 합계와 카운트를 초기화합니다. if mon >= len(sums\_seconds): sums\_seconds.append(0) counts.append(0) # 총 시간(초) 가져오기 seconds = live\_mons[mon][1].total\_seconds() # 합계에 추가하고 카운트 늘리기 sums\_seconds[mon] += seconds counts[mon] += 1 # 평균 계산 평균 = sums\_seconds[mon] / counts[mon] # 모니터 이름, 초, 평균을 목록에 추가합니다. live\_mons\_avg.append((live\_mons[mon][0], round(seconds, 2), round(average, 2))) # 평균을 기준으로 목록 정렬 sorted\_live\_mons = sorted(live\_mons\_avg, key=lambda x: x[2]) # 정렬된 목록을 인쇄합니다. for mon in range(len(sorted\_live\_mons)): listbox2.insert(tk.END,sorted\_live\_mons[mon][0] + ": " + str(sorted\_live\_mons[mon][1]) + " 평균: " + str(sorted\_live\_mons[mon][2])) # 죽은 모니터를 인쇄합니다. listbox2.insert(tk.END, "") listbox2.insert(tk.END, "데드 모니터: ( " + str(len(dead\_mons)) + " )") for mon in range(len(dead\_mons)): listbox2.insert(tk.END, dead\_mons[mon][0] + ": " + str(round(dead\_mons[mon][1].total\_seconds(), 2)) ) root.after(1000, refresh\_display)def button1\_clicked(): live\_mons, dead\_mons = get\_recent\_log\_lines() listbox2.delete(0, tk.END) listbox2.insert(tk.END,"실시간 모니터: ( " + str(len(live\_mons))) + " )") live\_mons\_avg = [] for mon in range(len(live\_mons)): seconds = live\_mons[mon][1].total\_seconds() listbox2.insert(tk.END, live\_mons[mon][0] + ": " + str(round(seconds, 2)) ) listbox2.insert(tk.END, "죽은 모니터: ( " + str(len(dead\_mons)) + " )") for mon in range(len(dead\_mons)): listbox2.insert(tk.END, dead\_mons[mon][0] + ": " + str(round(dead\_mons[mon][1].tota