From e909a8a92d0dc03149eeb403d3f3347b021a5f86 Mon Sep 17 00:00:00 2001 From: Larry Versaw Date: Wed, 3 Apr 2024 09:05:49 -0600 Subject: [PATCH] small improvements --- usfm/usfm_wizard.py | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/usfm/usfm_wizard.py b/usfm/usfm_wizard.py index e6be0e3c..f17aa5b3 100644 --- a/usfm/usfm_wizard.py +++ b/usfm/usfm_wizard.py @@ -24,6 +24,7 @@ import g_usfm2usx from txt2USFM import main from verifyUSFM import main +from inventory_chapter_labels import main from usfm_cleanup import main from mark_paragraphs import main from plaintext2usfm import main @@ -49,7 +50,7 @@ def __init__(self): self._build_steps(mainframe) self.process = 'SelectProcess' - self.activate_step('SelectProcess') + self.activate_step_byname('SelectProcess') self.bind('<>', self.onScriptMessage) self.bind('<>', self.onScriptProgress) self.bind('<>', self.onScriptEnd) @@ -63,7 +64,7 @@ def _build_steps(self, mainframe): g_verifyManifest, g_plaintext2usfm, g_usfm2usx): stepclass = getattr(sys.modules[S.__name__], S.stepname) step = stepclass(mainframe, mainapp=self) # create an instance of the class - self.steps[S.stepname] = step + self.steps[step.name()] = step for child in self.winfo_children(): child.grid_configure(padx=(25,15), pady=5) @@ -73,7 +74,8 @@ def normalize_window(self, *args): self.unbind("") def execute_script(self, module, count): - self.titleframe.start_progress(count) + if count > 0: + self.titleframe.start_progress(count) self.titleframe.tkraise() self.progress = "" self.current_script_module = sys.modules[module] @@ -107,11 +109,11 @@ def set_process(self, selection): # Returns the name of the step in the current process that should be # executed when the user presses the Back button. - def prevstep(self): + def prevstepname(self): gotostep = None match self.current_step.name(): case 'MarkParagraphs': - gotostep = 'VerifyUSFM' + gotostep = 'UsfmCleanup' case 'Plaintext2Usfm': gotostep = 'SelectProcess' case 'Txt2USFM': @@ -131,10 +133,10 @@ def prevstep(self): # Activates the previous step def step_back(self): - self.activate_step(self.prevstep()) + self.activate_step_byname(self.prevstepname()) # Returns the name of the next step in the current process - def nextstep(self): + def nextstepname(self): gotostep = None match self.current_step.name(): case 'MarkParagraphs': @@ -159,18 +161,21 @@ def nextstep(self): # Activates the next step, based the current process and what step we just finished. def step_next(self, copyparms=None): - self.activate_step(self.nextstep(), copyparms) + self.activate_step_byname(self.nextstepname(), copyparms) - def activate_step(self, stepname, copyparms=None): + def activate_step_byname(self, stepname, copyparms=None): if stepname: - self.current_step = self.steps[stepname] - self.titleframe.step_label['text'] = self.current_step.title() - section = self.config.get_section(stepname) - if copyparms: - for parm in copyparms: - section[parm] = copyparms[parm] - self.config.write_section(stepname, section) - self.current_step.show(section) + self.activate_step(self.steps[stepname], copyparms) + + def activate_step(self, step, copyparms=None): + self.current_step = step + self.titleframe.step_label['text'] = self.current_step.title() + section = self.config.get_section(step.name()) + if copyparms: + for parm in copyparms: + section[parm] = copyparms[parm] + self.config.write_section(step.name(), section) + self.current_step.show(section) # Called by one of the GUI modules. # Saves the specified values in the config file.