Update summary_tab.py

This commit is contained in:
CNlaojing
2025-03-09 18:35:05 +08:00
committed by GitHub
parent 05232e5f10
commit f6567577e9
+14 -2
View File
@@ -11,17 +11,29 @@ def build_summary_tab(self):
self.summary_tab.rowconfigure(0, weight=0) self.summary_tab.rowconfigure(0, weight=0)
self.summary_tab.rowconfigure(1, weight=1) self.summary_tab.rowconfigure(1, weight=1)
self.summary_tab.columnconfigure(0, weight=1) self.summary_tab.columnconfigure(0, weight=1)
self.summary_tab.columnconfigure(1, weight=0)
self.summary_tab.columnconfigure(2, weight=0)
load_btn = ctk.CTkButton(self.summary_tab, text="加载 global_summary.txt", command=self.load_global_summary, font=("Microsoft YaHei", 12)) load_btn = ctk.CTkButton(self.summary_tab, text="加载 global_summary.txt", command=self.load_global_summary, font=("Microsoft YaHei", 12))
load_btn.grid(row=0, column=0, padx=5, pady=5, sticky="w") load_btn.grid(row=0, column=0, padx=5, pady=5, sticky="w")
self.word_count_label = ctk.CTkLabel(self.summary_tab, text="字数:0", font=("Microsoft YaHei", 12))
self.word_count_label.grid(row=0, column=1, padx=5, pady=5, sticky="w")
save_btn = ctk.CTkButton(self.summary_tab, text="保存修改", command=self.save_global_summary, font=("Microsoft YaHei", 12)) save_btn = ctk.CTkButton(self.summary_tab, text="保存修改", command=self.save_global_summary, font=("Microsoft YaHei", 12))
save_btn.grid(row=0, column=0, padx=5, pady=5, sticky="e") save_btn.grid(row=0, column=2, padx=5, pady=5, sticky="e")
self.summary_text = ctk.CTkTextbox(self.summary_tab, wrap="word", font=("Microsoft YaHei", 12)) self.summary_text = ctk.CTkTextbox(self.summary_tab, wrap="word", font=("Microsoft YaHei", 12))
TextWidgetContextMenu(self.summary_text) TextWidgetContextMenu(self.summary_text)
self.summary_text.grid(row=1, column=0, sticky="nsew", padx=5, pady=5) self.summary_text.grid(row=1, column=0, sticky="nsew", padx=5, pady=5, columnspan=3)
def update_word_count(event=None):
text = self.summary_text.get("0.0", "end")
count = len(text) - 1
self.word_count_label.configure(text=f"字数:{count}")
self.summary_text.bind("<KeyRelease>", update_word_count)
self.summary_text.bind("<ButtonRelease>", update_word_count)
def load_global_summary(self): def load_global_summary(self):
filepath = self.filepath_var.get().strip() filepath = self.filepath_var.get().strip()
if not filepath: if not filepath: