Update character_tab.py
This commit is contained in:
+13
-2
@@ -15,12 +15,23 @@ def build_character_tab(self):
|
|||||||
load_btn = ctk.CTkButton(self.character_tab, text="加载 character_state.txt", command=self.load_character_state, font=("Microsoft YaHei", 12))
|
load_btn = ctk.CTkButton(self.character_tab, text="加载 character_state.txt", command=self.load_character_state, 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.character_wordcount_label = ctk.CTkLabel(self.character_tab, text="字数:0", font=("Microsoft YaHei", 12))
|
||||||
|
self.character_wordcount_label.grid(row=0, column=1, padx=5, pady=5, sticky="w")
|
||||||
|
|
||||||
save_btn = ctk.CTkButton(self.character_tab, text="保存修改", command=self.save_character_state, font=("Microsoft YaHei", 12))
|
save_btn = ctk.CTkButton(self.character_tab, text="保存修改", command=self.save_character_state, 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.character_text = ctk.CTkTextbox(self.character_tab, wrap="word", font=("Microsoft YaHei", 12))
|
self.character_text = ctk.CTkTextbox(self.character_tab, wrap="word", font=("Microsoft YaHei", 12))
|
||||||
|
|
||||||
|
def update_word_count(event=None):
|
||||||
|
text = self.character_text.get("0.0", "end-1c")
|
||||||
|
text_length = len(text)
|
||||||
|
self.character_wordcount_label.configure(text=f"字数:{text_length}")
|
||||||
|
|
||||||
|
self.character_text.bind("<KeyRelease>", update_word_count)
|
||||||
|
self.character_text.bind("<ButtonRelease>", update_word_count)
|
||||||
TextWidgetContextMenu(self.character_text)
|
TextWidgetContextMenu(self.character_text)
|
||||||
self.character_text.grid(row=1, column=0, sticky="nsew", padx=5, pady=5)
|
self.character_text.grid(row=1, column=0, sticky="nsew", padx=5, pady=5, columnspan=3)
|
||||||
|
|
||||||
def load_character_state(self):
|
def load_character_state(self):
|
||||||
filepath = self.filepath_var.get().strip()
|
filepath = self.filepath_var.get().strip()
|
||||||
|
|||||||
Reference in New Issue
Block a user