import tkinter as tk
from tkinter import messagebox
import threading
import queue
import time
def down():
for i in range(1, 100):
output_queue.put(f"下载附件 {i}\n")
time.sleep(0.3)
return
def on_download_click():
try:
download_thread = threading.Thread(target=down, args=())
download_thread.start()
except Exception as e:
messagebox.showerror("错误", "该日期段没有附件下载")
def update_output_text():
while not output_queue.empty():
output_text.insert(tk.END, output_queue.get())
# 检查滚动条是否在底部
scroll_position = scrollbar.get()
if not fm_main.manually_scrolled or scroll_position[1] == 1.0:
output_text.see(tk.END)
fm_main.after(100, update_output_text)
def on_scroll(*args):
# 判断滚动条是否在底部
scroll_position = scrollbar.get()
if scroll_position[1] == 1.0:
fm_main.manually_scrolled = False
else:
fm_main.manually_scrolled = True
if __name__ == '__main__':
fm_main =
tk.Tk()
fm_main.title("邮件附件批量下载_v1.0")
fm_main.geometry('600x300')
fm_main.resizable(0, 0)
btn1 = tk.Button(fm_main, text="下载", font=("Arial", 13), width=25, height=2, command=on_download_click)
btn1.pack()
scrollbar = tk.Scrollbar(fm_main)
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
output_text = tk.Text(fm_main, font=("Arial", 12), width=60, height=10)
output_text.pack(side=tk.LEFT, fill=tk.BOTH)
output_text.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=output_text.yview)
output_queue = queue.Queue()
fm_main.after(100, update_output_text)
output_text.bind("<MouseWheel>", on_scroll)
output_text.bind("<Button-4>", on_scroll)
output_text.bind("<Button-5>", on_scroll)
fm_main.manually_scrolled = False
fm_main.mainloop()
问的 chatgpt3.5 的,你看看能运行么?