From 78ff0d730b0c6f1600091a94527b35452bdb6d6f Mon Sep 17 00:00:00 2001 From: Santi Santichaivekin <19219105+ssantichaivekin@users.noreply.github.com> Date: Mon, 10 Aug 2020 08:03:23 +0700 Subject: [PATCH] GUI: Fix toolbar error when changing reconciliation boolean options (#224) Problem: the matplotlib toolbar could not be deleted properly, so it raises an exception. This is because when we update the toolbar for the "one per reconciliation windows," it creates a new toolbar using the code ```python toolbar = NavigationToolbar2Tk(self.canvas, self.frame) ``` This toolbar variable disappears after the update function finishes. However, when we remove the toolbar, we call `self.toolbar.destroy()`. Solution: tie the toolbar variable to self at creation ```python self.toolbar = NavigationToolbar2Tk(self.canvas, self.frame) ``` Tested on macOS Catalina 10.15.5, can check/uncheck boolean options in #223 correctly. --- empress_gui.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/empress_gui.py b/empress_gui.py index 23b2ce8a..ca0d951d 100644 --- a/empress_gui.py +++ b/empress_gui.py @@ -962,8 +962,8 @@ def update_median_recons(self): self.canvas.draw() self.canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=True) # Recreate the toolbar - toolbar = NavigationToolbar2Tk(self.canvas, self.frame) - toolbar.update() + self.toolbar = NavigationToolbar2Tk(self.canvas, self.frame) + self.toolbar.update() # p-value Histogram class PValueHistogramWindow(tk.Frame):