From d993dfbb021f560da1a4b9de938e46ad305714e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20B=C3=A9lair?= Date: Thu, 14 Aug 2025 09:58:29 +0200 Subject: [PATCH] aa-notify gui: Fix undefined variable when ttkthemes is not installed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When ttkthemes is not installed, bg_color is undefined. We don't use it in that case. Signed-off-by: Maxime Bélair --- utils/apparmor/gui.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/utils/apparmor/gui.py b/utils/apparmor/gui.py index e32dd5534..a5c97518c 100644 --- a/utils/apparmor/gui.py +++ b/utils/apparmor/gui.py @@ -158,17 +158,18 @@ class ShowMoreGUIAggregated(GUI): self.text_display = tk.Text(self.label_frame, wrap='word', height=40, width=100, yscrollcommand=self.scrollbar.set) + kwargs = { + "height": self.text_display.winfo_reqheight() - 4, # The border are *inside* the canvas but *outside* the textbox. I need to remove 4px (2*the size of the borders) to get the same size + "width": self.text_display.winfo_reqwidth() - 4, + "borderwidth": self.text_display['borderwidth'], + "relief": self.text_display['relief'], + "yscrollcommand": self.scrollbar.set, + } + if ttkthemes: self.text_display.configure(background=self.bg_color, foreground=self.fg_color) - self.canvas = tk.Canvas( - self.label_frame, - background=self.bg_color, - height=self.text_display.winfo_reqheight() - 4, # The border are *inside* the canvas but *outside* the textbox. I need to remove 4px (2*the size of the borders) to get the same size - width=self.text_display.winfo_reqwidth() - 4, - borderwidth=self.text_display['borderwidth'], - relief=self.text_display['relief'], - yscrollcommand=self.scrollbar.set - ) + kwargs['background'] = self.bg_color + self.canvas = tk.Canvas(self.label_frame, **kwargs) self.inner_frame = ttk.Frame(self.canvas) self.canvas.create_window((2, 2), window=self.inner_frame, anchor='nw')