From e2093b5b48ec71a16f9a78ceb390dc9b0c7e3f73 Mon Sep 17 00:00:00 2001 From: Interitio Date: Tue, 6 Jan 2026 01:15:49 +1000 Subject: [PATCH] Add menu option to reload rulefile --- src/beanify/gui/mainwindow.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/beanify/gui/mainwindow.py b/src/beanify/gui/mainwindow.py index bac7226..9e2b3b7 100644 --- a/src/beanify/gui/mainwindow.py +++ b/src/beanify/gui/mainwindow.py @@ -70,7 +70,7 @@ class MainWindow(ThemedTk): menu_file.add_command(label="Export Transactions", command=self.do_export_txn) menu_file.add_separator() menu_file.add_command(label="Save Rules", command=self.do_save_rules) - # menu_file.add_command(label="Reload Rules", command=self.do_save_rules) + menu_file.add_command(label="Reload Rules", command=self.do_reload_rules) menu_file.add_separator() menu_file.add_command(label="Exit", command=lambda: self.destroy()) self.menubar.add_cascade(menu=menu_file, label="File") @@ -175,17 +175,22 @@ class MainWindow(ThemedTk): self.ruleset.add_rule(rule) # Adding a rule means a full regeneration + self.regenerate_rows() + + self.update_status(f"Rule created! {affected} transactions affected.") + + def regenerate_rows(self): + """ + Fully regenerate rows (incl in the editor) from the ruleset, aside from custom. + """ for record in self.rows: if record not in self.custom: txn = self.converter.convert(record, self.ruleset) self.rows[record] = txn - # Tell the table to regenerate self.rowtree.update_rows(self.rows) self.rebuild_account_cache() - self.update_status(f"Rule created! {affected} transactions affected.") - def initial_ingest(self): if self.files: rows = {} @@ -309,4 +314,12 @@ class MainWindow(ThemedTk): self.account_cache.clear() self.account_cache |= cache - def do_reapply_rules(self): ... + def do_reload_rules(self): + """ + Reload the ruleset (usually from disk). + + This lets us edit the rule table by saving, editing, and loading the rules, + even though we don't have a built-in rule editor yet. + """ + self.ruleset.reload_rules() + self.regenerate_rows()