From 2c8a10921e8e442eda8480ee5b95c16aad0b087b Mon Sep 17 00:00:00 2001 From: octimot Date: Fri, 16 Feb 2024 11:27:13 +0100 Subject: [PATCH] Reload transcriptions and stories when creating new windows --- storytoolkitai/ui/toolkit_ui.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/storytoolkitai/ui/toolkit_ui.py b/storytoolkitai/ui/toolkit_ui.py index 0aac267..6ad536f 100644 --- a/storytoolkitai/ui/toolkit_ui.py +++ b/storytoolkitai/ui/toolkit_ui.py @@ -12248,6 +12248,9 @@ def open_transcription_window(self, title=None, transcription_file_path=None, has_menubar=True ): + # reload the transcription object + transcription.reload_from_file(save_first=True) + # add the Transcription object to this window self.t_edit_obj.set_window_transcription(t_window_id, transcription) @@ -12256,6 +12259,14 @@ def open_transcription_window(self, title=None, transcription_file_path=None, # THE THREE WINDOW COLUMN FRAMES t_window = self.get_window_by_id(t_window_id) + # if the transcription name is different from the current title, change the title + if transcription.name and transcription.name != title: + # but only if the transcription name is not empty + t_window.title(transcription.name) + + # we should also update the main window since the transcription.name is usually displayed there too + self.update_main_window() + # create the left frame left_frame = ctk.CTkFrame(t_window, name='left_frame', **self.ctk_frame_transparent) left_frame.grid(row=0, column=0, sticky="ns", **self.ctk_side_frame_button_paddings) @@ -16061,6 +16072,17 @@ def open_story_editor_window(self, title=None, story_file_path=None): # get the window window = self.get_window_by_id(window_id) + # reload the story object from file just to make sure that we have the latest data + story.reload_from_file(save_first=True) + + # if the story name is different from the current title, change the title + if story.name and story.name != title: + # but only if the story name is not empty + window.title(story.name) + + # we should also update the main window since the story.name is usually displayed there too + self.update_main_window() + # attach the story object to the window window.story = story